J
Jess12
Hi,
I'm trying to figure out what's missing from my code. After adding a record,
if its not already in the combo box, I need to update my form and subform to
show the new record and related records (in the subform). The form is
programmed to automatically add a client if the name is not already in the
combo box. When the new record is created, I need my form and subform to
show the new record, but it is showing information for a different record.
The master and Child relationships are set on the forms, but I need some kind
of code to make the connection between the new client that was added to the
combo box and the rest of the fields on the form. Here's my Not In List
event code:
Private Sub Combo6_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Client...")
If i = vbYes Then
strSQL = "Insert Into [Clients] ([ClientName]) " & "values ('" &
NewData & "');"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
[Forms]![Clients Form]![CallLog subform].Requery
End Sub
I'm trying to figure out what's missing from my code. After adding a record,
if its not already in the combo box, I need to update my form and subform to
show the new record and related records (in the subform). The form is
programmed to automatically add a client if the name is not already in the
combo box. When the new record is created, I need my form and subform to
show the new record, but it is showing information for a different record.
The master and Child relationships are set on the forms, but I need some kind
of code to make the connection between the new client that was added to the
combo box and the rest of the fields on the form. Here's my Not In List
event code:
Private Sub Combo6_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Client...")
If i = vbYes Then
strSQL = "Insert Into [Clients] ([ClientName]) " & "values ('" &
NewData & "');"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
[Forms]![Clients Form]![CallLog subform].Requery
End Sub