Stupid Message Box Question

joesstlouis

Registered User.
Local time
Today, 08:00
Joined
Feb 20, 2006
Messages
10
I'm currently trying to get a button working that will check the contents of a field for a value, and if nothing is selected I want it to prompt the user to select something. Here's my code:

Private Sub Command47_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCustomerInf"
stLinkCriteria = "[CustomerID]=" & Me![CustomerID]

If [CustomerID] = "" Then
MsgBox "Please Select a Company Name", vbInformation, "Warning"
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

End Sub

For some reason I can't get this working, what am I doing wrong?

The error I'm getting when trying the button is Run-time error 3075: Syntax Error (Missing operator) in query expression '[CustomerID]='
 
Last edited:
if CustomerID = "" Then
MsgBox "Please Select a Company Name", vbInformation, "Warning"
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
 
Still no luck... if I select a CustomerID (Name) from the list it works fine, if I don't I get the error...
 
What does this question have to do with the "Table" section of the forum?

If IsNull(CustomerID) or CustomerID = "" Then

Is the CustomerID the name of the text box or the name of the field from the table? You need to use a proper naming convention for your objects! Access will get confused if you use the default names from a wizard and allow the text box and the field name to be the same.

You should name your text box like ... txtCustomerID

If IsNull(txtCustomerID) or txtCustomerID = "" Then
 

Users who are viewing this thread

Back
Top Bottom