strWhere Error

rywello

Registered User.
Local time
Today, 12:51
Joined
Jan 13, 2016
Messages
68
I am using the below code to search in a number field. When I enter text in the field, it asks for a parameter value before throwing an error. How can I get it to throw an error that says "Please enter a numeric value" instead?

If Not IsNull(Me.number) Then
strWhere = strWhere & "([NumberField] = " & Me.number & ") AND "

Thanks.
 
Number is a reserved word - change the name of your control

Alternatively number is not null and not a number, i.e. text
 
Sorry, I was just giving an example. My code is really:

If Not IsNull(Me.nomkey) Then
strWhere = strWhere & "([Nom Key] = " & Me.nomkey & ") AND "
 
I have the code on the on click event of a button. I still cannot get the validation to work.
 
hmm - suggest you read the link I provided properly - validation rule is a property, not an event
 
I can not use a validation rule as I import the table into my database and it won't allow me to save the validation rule on the field. Is there a way that I can add it to the VBA code I listed above? Thanks.
 

Users who are viewing this thread

Back
Top Bottom