Form Event Procedure Help
I have asked questions in this forum previously and have received helpful information. Thank you.:) I am still an infant programmer and I appreciate all the help I receive. So here is my next question.
I am using a command button, âEdit Contact Informationâ, to close the form âfrmInventoryTrackingâ and opening the form âfrmCustomerContactEditâ. The command button is intended to close "frmInventoryTracking", open "frmCustomerContactEdit" and go directly to the selected âCustomerIDâ (the CustomerID was entered in the "CustomerID" Combobox in "frmInventoryTracking" before clicking "Edit Contact Information"). Form "frmCustomerContactEdit" is bound to the table "tblCustomers". The information that is being edited is "ContactName" and "FaxNumber".
The command button works correctly if there is data in the CustomerID ComboBox. However, if there is not any data in the CustomerID ComboBox, I receive the following syntax error âSyntax Error (missing operator) in query expression â[CustomerID]=â. When I click OK, form âfrmInventoryTrackingâ still closes and the entire database disappears.
I would like to press OK and put another error message box âMust select Customerâ on the screen, click OK and then return to âfrmInventoryTrackingâ.
Here is the code I have written.
Private Sub Edit_Contact_Information_Click()
On Error GoTo Err_CustomerContactEdit_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCustomerContactEdit"
stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Any help will again be appreciated.