I have a lookup combobox to select a phone number, with input mask including the "-"(123-1234 for example). The literal is saved with the number in the table. The combo is limited to the list. The not-in-list event brings up a form to add a new number (with some other data required). The problem lies in that the acdataerradded does not suppress the error message. My theory is that since the new entry in the lookup combo does not include the literal, the not in list event fires again (because the add new entry form saved the new entry with the literal). Do I have this correct? How do I get the proper behavior?
Private Sub PharmID_NotInList(NewData As String, Response As Integer)
Dim intAns As Integer
'Open add pharmacy form in dialog format, open args = PharmID.text (NewData)
intAns = MsgBox("That number is not in the database. Do you want to add it?", vbYesNo, "New pharmacy?"
If intAns = vbYes Then
NewData = Format(NewData, "&&&-&&&&"
DoCmd.OpenForm "frmPharmacy", , , , acAdd, acDialog, NewData
If IsNull(DLookup("Name", "tblPharmacy", "[ph1] = """ & NewData & """"
) Then
MsgBox "It's null!"
Response = acDataErrContinue
Else
MsgBox "That pharmacy number is now in the list"
Response = acDataErrAdded
End If
Exit Sub
End If
Response = acDataErrDisplay
Private Sub PharmID_NotInList(NewData As String, Response As Integer)
Dim intAns As Integer
'Open add pharmacy form in dialog format, open args = PharmID.text (NewData)
intAns = MsgBox("That number is not in the database. Do you want to add it?", vbYesNo, "New pharmacy?"
If intAns = vbYes Then
NewData = Format(NewData, "&&&-&&&&"
DoCmd.OpenForm "frmPharmacy", , , , acAdd, acDialog, NewData
If IsNull(DLookup("Name", "tblPharmacy", "[ph1] = """ & NewData & """"
MsgBox "It's null!"
Response = acDataErrContinue
Else
MsgBox "That pharmacy number is now in the list"
Response = acDataErrAdded
End If
Exit Sub
End If
Response = acDataErrDisplay