I have a customer form where I need a button that should copy/insert the CustomerID value to CustomerID field on the main form.
The CustomerID on the main form is a combobox with a query that selects values from the customer table.
I tried this code and it opens the main form with CustomerID field empty. I guess it is because of the CustomerID on the main form being a combobox.
Could you please advise how to solve this?
The CustomerID on the main form is a combobox with a query that selects values from the customer table.
I tried this code and it opens the main form with CustomerID field empty. I guess it is because of the CustomerID on the main form being a combobox.
Code:
Private Sub InserttoMainOrder_Click()
If IsNull(Me.CustomerID) Then
MsgBox "Please Select a Company First", vbOKOnly
Me.CustomerID.SetFocus
Exit Sub
End If
DoCmd.OpenForm "frmMainOrders", , , "CustomerID = " & Me.CustomerID
End Sub
Could you please advise how to solve this?