I have the following code and I wanted to have the NOTInLIst EVent fire the AFterUpdate event after my form opens saves the new record and closes.
How can I call this procedure? I have put it in a couple of different places but nothing works. What can I do?
Private Sub TWIC_Number_AfterUpdate()
Me.FName = DLookup("FName", "qryVGSearchTruckDriver1")
Me.LName = DLookup("LName", "qryVGSearchTruckDriver1")
Private Sub TWIC_Number_NotInList(NewData As String, Response As Integer)
Dim Msg As String
Dim CR As String
CR = Chr$(13)
' Exit this subroutine if the combo box was cleared.
If NewData = "" Then
' Ask the user if he or she wishes to add the new customer.
Msg = "'" & NewData & "' is not in the list." & CR & CR
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
' If the user chose Yes, start the Customers form in data entry
' mode as a dialog form, passing the new company name in
' NewData to the OpenForm method's OpenArgs argument. The
' OpenArgs argument is used in Customer form's Form_Load event
DoCmd.OpenForm "frmVGTRuckDriver1Srch", , , , acAdd, acDialog, NewData
' Look for the customer the user created in the TruckDriver1Srch form.
Result = DLookup("[TWIC_Number]", "MGNameAddressPhone", _
"[TWIC_Number]='" & NewData & "'")
If IsNull(Result) Then
' If the customer was not created, set the Response argument
' to suppress an error message and undo changes.
Response = acDataErrContinue
' Display a customized message.
MsgBox "Please try again!"
' If the customer was created, set the Response argument to
' indicate that new data is being added.
Response = acDataErrAdded