An if statement in a query

  • Thread starter Thread starter Belinda7237
  • Start date Start date
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.
 
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
 
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.
 
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.
 
Back
Top