an if/then in the criteria for a query

G

Guest

Okay, I am trying to build a query in the query builder.
I have 3 fields. Two are foreign serialID fields. If either one has a
value then I calculate a boolean flag.

criteria entered om field1 & field two= "if" > 0=1

I want to add a value to a category field based on which one has the flag.
This is the jest of what I want in the criteria property for the 3rd field.
I don't know how to do the if/then.
Something like:
"if" field1 = 1 categoryTypeA;
'if" field2 = 1 categoryTypeB
It doesn't like the semi-colon. Why does it have the apostrophes in the if
statement?
thanks a lot
 
D

David F Cox

look up IIF function in Help.

IIF(test, result if true, result if false)

e.g in query builder:

ans: IIF([yourfield]>0, "GT zero","LT zero")
 
G

Guest

I noticed the IIF() function. But in this case I think there are two if
statements. There may be a null value in one. I may be wrong on this but
I think it is
if there is one flag then somethign. If there is another flag then
something else.--
Janis


David F Cox said:
look up IIF function in Help.

IIF(test, result if true, result if false)

e.g in query builder:

ans: IIF([yourfield]>0, "GT zero","LT zero")
 
J

Jeff Boyce

You can "nest" IIF() statements to cover more than two test conditions.

Regards

Jeff Boyce
Microsoft Office/Access MVP

FilemakerPro_Developer said:
I noticed the IIF() function. But in this case I think there are two if
statements. There may be a null value in one. I may be wrong on this
but
I think it is
if there is one flag then somethign. If there is another flag then
something else.--
Janis


David F Cox said:
look up IIF function in Help.

IIF(test, result if true, result if false)

e.g in query builder:

ans: IIF([yourfield]>0, "GT zero","LT zero")

"FilemakerPro_Developer"
<[email protected]>
wrote in message
Okay, I am trying to build a query in the query builder.
I have 3 fields. Two are foreign serialID fields. If either one has a
value then I calculate a boolean flag.

criteria entered om field1 & field two= "if" > 0=1

I want to add a value to a category field based on which one has the
flag.
This is the jest of what I want in the criteria property for the 3rd
field.
I don't know how to do the if/then.
Something like:
"if" field1 = 1 categoryTypeA;
'if" field2 = 1 categoryTypeB
It doesn't like the semi-colon. Why does it have the apostrophes in
the
if
statement?
thanks a lot
 
D

David F Cox

You can nest function, test for NULL and set fields to NULL:-

IIF(IIF(IIF(....)),IIF(IIF(....)))

but do not blame us if tomorrow you hates yesterday you for writing too
complex and obscure stuff.


Jeff Boyce said:
You can "nest" IIF() statements to cover more than two test conditions.

Regards

Jeff Boyce
Microsoft Office/Access MVP

"FilemakerPro_Developer" <[email protected]>
wrote in message
I noticed the IIF() function. But in this case I think there are two if
statements. There may be a null value in one. I may be wrong on this
but
I think it is
if there is one flag then somethign. If there is another flag then
something else.--
Janis


David F Cox said:
look up IIF function in Help.

IIF(test, result if true, result if false)

e.g in query builder:

ans: IIF([yourfield]>0, "GT zero","LT zero")

"FilemakerPro_Developer"
<[email protected]>
wrote in message

Okay, I am trying to build a query in the query builder.
I have 3 fields. Two are foreign serialID fields. If either one has
a
value then I calculate a boolean flag.

criteria entered om field1 & field two= "if" > 0=1

I want to add a value to a category field based on which one has the
flag.
This is the jest of what I want in the criteria property for the 3rd
field.
I don't know how to do the if/then.
Something like:
"if" field1 = 1 categoryTypeA;
'if" field2 = 1 categoryTypeB
It doesn't like the semi-colon. Why does it have the apostrophes in
the
if
statement?
thanks a lot
 

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

Similar Threads

Query Parameter using multiple options 0
Access Dcount (multiple criteria) 3
Finding null 4
Queries 3
query criteria from form 7
Setting criteria in query 2
2 independent criteria in a query 2
Hyperlink 1

Top