Well, I'm about to give up on this ... I'm just not getting this to work.
My code as it currently stands:
Code:
Private Sub Distributor_NotInList(NewData As String, Response As Integer)
On Error GoTo Distributor_NotInList_Err
Dim intAnswer As Integer
'Display a message asking user if they want to add the new data to the list
intAnswer = MsgBox("The company " & Chr(34) & NewData & _
Chr(34) & " is not on file." & vbCrLf & _
"Would you like to create a record for " & Chr(34) & NewData & Chr(34) & " ?" _
, vbQuestion + vbYesNo, "HUG Presentation") 'displays a question mark and yes & no buttons. The box has a custom title
'If the answer is yes, open the Distributor form as a pop-up and modal
If intAnswer = vbYes Then
DoCmd.OpenForm "DistributorsPopup", , , , acFormAdd, acDialog, NewData
'tell Access the data has been added and to requery the combo box.
Response = acDataErrAdded
Else
'Remind user to choose from the list
MsgBox "Please choose a company from the list." _
, vbInformation, "HUG Presentation"
'tell Access to ignore the NotInList error and continue
Response = acDataErrContinue
End If
Distributor_NotInList_Exit:
Exit Sub
Distributor_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume Distributor_NotInList_Exit
End Sub
Code for the DistributorsPopup form:
Code:
Private Sub Form_Open(NewData As String, Cancel As Integer)
If Me.NewRecord Then
Me!CompName = Me.OpenArgs
End If
End Sub
I did change the name of the form so there were no spaces.
I get an error that states "The OpenForm action was canceled."
I may try the code in the message from Moke123.
Thanks all, for your patience with me.
Susie
Kansas