An if statement in a query

B

Belinda7237

I am trying to write an if statement in a query and I havent got it quite
right.
I wanted to create a defective package field where if the package had an
error if would return a 1 in my calculated field, otherwise it would return a
0. The expression i wrote in access is:

Defective Package: =If([Total Errors for Package]>0,1,0)

but it doesnt like it.
 
J

Jeanette Cunningham

Belinda,
You are very close, write it like this if the calculated field is in a query

Defective Package: IIf([Total Errors for Package]>0,1,0)

there are two I's in the IIf function.


Jeanette Cunningham
 
B

Belinda7237

thanks, it worked!

Jeanette Cunningham said:
Belinda,
You are very close, write it like this if the calculated field is in a query

Defective Package: IIf([Total Errors for Package]>0,1,0)

there are two I's in the IIf function.


Jeanette Cunningham




Belinda7237 said:
I am trying to write an if statement in a query and I havent got it quite
right.
I wanted to create a defective package field where if the package had an
error if would return a 1 in my calculated field, otherwise it would
return a
0. The expression i wrote in access is:

Defective Package: =If([Total Errors for Package]>0,1,0)

but it doesnt like it.
 
V

viktor chuzhakin

Belinda7237 said:
I am trying to write an if statement in a query and I havent got it quite
right.
I wanted to create a defective package field where if the package had an
error if would return a 1 in my calculated field, otherwise it would
return a
0. The expression i wrote in access is:

Defective Package: =If([Total Errors for Package]>0,1,0)

but it doesnt like it.
 

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