field Is Null/Is Not Null criterion and IIf function

G

Guest

I would like to formulate a query that will determine if the criterion of a
field is to be Is Null or Is Not Null depending on the data of another field
in equijoined table. I am trying to use the IIf function to build this
criterion in design view using:

IIf([Other_Table]![Determining_Field]="X",Is Not Null, Is Null)

However, the SQL query I get is:
WHERE ...
([This_Table]![This_Field]=(IIf([Other_Table]![Determining_Field]="X",Is Not
Null, Is Null)) ...

which is obviously not what I want to determine but...

WHERE ...
([This_Table]![This_Field] IS {NOT} NULL) ...

Could you please advise me the syntax error that is occuring?
 
M

Marshall Barton

J.T. Leeman said:
I would like to formulate a query that will determine if the criterion of a
field is to be Is Null or Is Not Null depending on the data of another field
in equijoined table. I am trying to use the IIf function to build this
criterion in design view using:

IIf([Other_Table]![Determining_Field]="X",Is Not Null, Is Null)

However, the SQL query I get is:
WHERE ...
([This_Table]![This_Field]=(IIf([Other_Table]![Determining_Field]="X",Is Not
Null, Is Null)) ...

which is obviously not what I want to determine but...

WHERE ...
([This_Table]![This_Field] IS {NOT} NULL) ...

Could you please advise me the syntax error that is occuring?


IIf([Other_Table]![Determining_Field]="X",
[This_Table]![This_Field] Is Not Null,
[This_Table]![This_Field] Is Null)
 
G

Guest

Marshall Barton said:
J.T. Leeman said:
I would like to formulate a query that will determine if the criterion of a
field is to be Is Null or Is Not Null depending on the data of another field
in equijoined table. I am trying to use the IIf function to build this
criterion in design view using:

IIf([Other_Table]![Determining_Field]="X",Is Not Null, Is Null)

However, the SQL query I get is:
WHERE ...
([This_Table]![This_Field]=(IIf([Other_Table]![Determining_Field]="X",Is Not
Null, Is Null)) ...

which is obviously not what I want to determine but...

WHERE ...
([This_Table]![This_Field] IS {NOT} NULL) ...

Could you please advise me the syntax error that is occuring?


IIf([Other_Table]![Determining_Field]="X",
[This_Table]![This_Field] Is Not Null,
[This_Table]![This_Field] Is Null)
Hi - that is what I originally figured was the answer to my problem... but
I keep getting the error: "The expression is typed incorrectly or it is too
complex to be evaluated"

Reviewing the SQL command that corresponds to the design view, I am still
getting
WHERE ..
([This_Table]![This_Field]=(IIf([Other_Table]![Determining_Field]="X",[This_Table]![This_Field] Is Not
Null, [This_Table]![This_Field]Is Null)) ...
 
M

Marshall Barton

J.T. Leeman said:
I would like to formulate a query that will determine if the criterion of a
field is to be Is Null or Is Not Null depending on the data of another field
in equijoined table. I am trying to use the IIf function to build this
criterion in design view using:

IIf([Other_Table]![Determining_Field]="X",Is Not Null, Is Null)

However, the SQL query I get is:
WHERE ...
([This_Table]![This_Field]=(IIf([Other_Table]![Determining_Field]="X",Is Not
Null, Is Null)) ...

which is obviously not what I want to determine but...

WHERE ...
([This_Table]![This_Field] IS {NOT} NULL) ...

Could you please advise me the syntax error that is occuring?
Marshall Barton said:
IIf([Other_Table]![Determining_Field]="X",
[This_Table]![This_Field] Is Not Null,
[This_Table]![This_Field] Is Null)
J.T. Leeman said:
Hi - that is what I originally figured was the answer to my problem... but
I keep getting the error: "The expression is typed incorrectly or it is too
complex to be evaluated"

Reviewing the SQL command that corresponds to the design view, I am still
getting
WHERE ...
([This_Table]![This_Field]=(IIf([Other_Table]![Determining_Field]="X",[This_Table]![This_Field] Is Not
Null, [This_Table]![This_Field]Is Null)) ...


This is one of those cases where the QBE just gets in the
way. Switch to SQL view and edit the where condition to get
rid of the extraneous
[This_Table]![This_Field]=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top