A
allie357
Here is the code I have for my not in list event:
It is giving me an error at the If IsNull(DLookup) line. My combo box
runs of a query that pulls the Violator's Last Name and First Name from
the Violator's table and displays them Violator's Last Name, Violator's
Last Name
with
Violator's Name: [Violator's Last Name] & ", " &
tbl_Violators![Violator's First Name]
Now I need this code to open the New Violator Form and allow the user
to add the Last Name into a field and the first name into a field to
add them to the table and requery the list to add the new addition. My
code is not working now. Please help.
Private Sub Combo111_NotInList(NewData As String, Response As
Integer)
If MsgBox("That violator is not in the list." & _
"Would you like to add a new violator?", vbYesNo) = vbYes
Then
' Open the form to add the new violator.
DoCmd.OpenForm "frmNewViolator", , , , acFormAdd, acDialog,
NewData
If IsNull(DLookup("Violator_ID", "tblViolators", _
"Violator's Last Name = """ & NewData & """")) Then
Response = acDataErrContinue
Else
Response = acDataErrAdded
Me.cbo.Violator_ID
End If
Else
Response = acDataErrContinue
End If
End Sub
It is giving me an error at the If IsNull(DLookup) line. My combo box
runs of a query that pulls the Violator's Last Name and First Name from
the Violator's table and displays them Violator's Last Name, Violator's
Last Name
with
Violator's Name: [Violator's Last Name] & ", " &
tbl_Violators![Violator's First Name]
Now I need this code to open the New Violator Form and allow the user
to add the Last Name into a field and the first name into a field to
add them to the table and requery the list to add the new addition. My
code is not working now. Please help.
Private Sub Combo111_NotInList(NewData As String, Response As
Integer)
If MsgBox("That violator is not in the list." & _
"Would you like to add a new violator?", vbYesNo) = vbYes
Then
' Open the form to add the new violator.
DoCmd.OpenForm "frmNewViolator", , , , acFormAdd, acDialog,
NewData
If IsNull(DLookup("Violator_ID", "tblViolators", _
"Violator's Last Name = """ & NewData & """")) Then
Response = acDataErrContinue
Else
Response = acDataErrAdded
Me.cbo.Violator_ID
End If
Else
Response = acDataErrContinue
End If
End Sub