Event Procedure help
To start, unfortunately, we still use Access 97 at work. Hopefully we will be converting to Access 2002 in the near future.
The CustomerNameID ComboBox is Bound to tblCustomers. Only the Customer Name is displayed in this ComboBox. I put the Event Procedure in the âOn Not in Listâ event property field
I would like to create an Event Procedure that will ask âAdd New Customerâ then open the data entry form frmCustomers to add the New Customer Name, Phone Number, Fax Number and Contact Name. After the information is filled in, I would like it to close form frmCustomers and return to the CustomerNameID ComboBox and have the CustomerNameID ComboBox accept the newly Customer Name.
Below is what I have so far. I put the Event Procedure in the âOn Not in Listâ event property field.
Private Sub CustomerNameID_NotInList(NewData As String, Response As Integer)
Dim db As Database
Set db = CurrentDb()
If vbYes = MsgBox(NewData & " -- Add New Customer?", vbYesNo) Then
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCustomer"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub
This VBA Code will open the form frmCustomers and allow me to add the new information. After I close frmCustomers, I return to the CustomerNameID ComboBox, however, I receive an information box that states âThe text you entered isnât an item in the listâ, âSelect an item from the list, or enter text that matches one of the itemsâ. How do I write the Code to Update the newly added Customer to the CustomerNameID ComboBox?
Any help would be greatly appreciated.
D. Bartelt
__________________
D. Bartelt
|