Run-time error 424

cuttsy

The Great Pretender
Local time
Today, 10:17
Joined
Jun 9, 2004
Messages
164
Here is the first part of an IF statement that has a problem. I was wondering if this was a syntax error or if there is something fundamentally wrong with it?

j1, s1, d1 e.t.c. are drop down boxes.

If Me!j1 Is Not Null And Me!s1 Is Null And Me!d1 Is Null And Me!c1 Is Null And Me!a1 Is Null Then

On Error GoTo Err_RunQuery_Click

Dim stDocName As String

stDocName = "JobTitle"
DoCmd.OpenQuery stDocName, acNormal, acEdit
 
cuttsy said:
I was wondering if this was a syntax error or if there is something fundamentally wrong with it?

It's not VBA, that's what's wrong with it. Is Null and Is Not Null are SQL criteria and not valid VBA.

For VBA, use the IsNull() function:

Code:
If Not IsNull(Me.j1) And IsNull(Me.s1) And IsNull(Me.d1) And IsNull(Me.c1) And IsNull(Me.a1) Then

I'm a little suspicious that you may be going "the long way around" with your problem here. What is it you are trying to do as I'm sure there will be a simpler way?
 
solved

Its okay I have it working. Using IsNull()
 
I have a form with drop down boxes for school district, category, age-range etc. The user picks from the lists and clicks a run query button and the if statement is deciding which query to run out of a possible 17.

I always do things the longway round and then realise 2 weeks later. :rolleyes:
 

Users who are viewing this thread

Back
Top Bottom