IIF Statement #Error

R

rml

I have a query with three fields. ID, Standard, Report

I'm trying to use the following code in the field line:

Report:
IIf([Standard]=1,"abc",IIf([Standard]=2,"stop",IIf([Standard]=3,"nice")))
But the values in Report are #Error?

What am I doing wrong? Thanks.
 
R

rml

Can you show me what you mean? Example? Thanks.

Jerry Whittle said:
You are missing the False part after "nice".
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


rml said:
I have a query with three fields. ID, Standard, Report

I'm trying to use the following code in the field line:

Report:
IIf([Standard]=1,"abc",IIf([Standard]=2,"stop",IIf([Standard]=3,"nice")))
But the values in Report are #Error?

What am I doing wrong? Thanks.
 
N

NeonSky via AccessMonster.com

I think what Jerry means is that you need to establish a "If then else"
statement. An IIF statement works in a fashion that essentially says "If this
criteria is met then do this, if the criteria is not met then do that (else)".
Your IIF statement is saying "If this criteria is met then do this" three
times, without establishing the "if the criteria is not met then do that
(else)" portion.

If [Standard] only has applicable values of 1, 2, or 3 then you can have your
else statement do nothing and it should work. That last comma followed by the
two quotes fullfills the else portion.

IIf([Standard]=1,"abc",IIf([Standard]=2,"stop",IIf([Standard]=3,"nice","")))


I have a query with three fields. ID, Standard, Report

I'm trying to use the following code in the field line:

Report:
IIf([Standard]=1,"abc",IIf([Standard]=2,"stop",IIf([Standard]=3,"nice")))
But the values in Report are #Error?

What am I doing wrong? Thanks.
 
R

rml

I'm still getting an #Error for the value? Any more ideas?

I'm putting it on the field line in my query.

Type:
IIf([Standard]=1,"abc",IIf([Standard]=2,"stop",IIf([Standard]=3,"nice","")))

Thanks.

NeonSky via AccessMonster.com said:
I think what Jerry means is that you need to establish a "If then else"
statement. An IIF statement works in a fashion that essentially says "If this
criteria is met then do this, if the criteria is not met then do that (else)".
Your IIF statement is saying "If this criteria is met then do this" three
times, without establishing the "if the criteria is not met then do that
(else)" portion.

If [Standard] only has applicable values of 1, 2, or 3 then you can have your
else statement do nothing and it should work. That last comma followed by the
two quotes fullfills the else portion.

IIf([Standard]=1,"abc",IIf([Standard]=2,"stop",IIf([Standard]=3,"nice","")))


I have a query with three fields. ID, Standard, Report

I'm trying to use the following code in the field line:

Report:
IIf([Standard]=1,"abc",IIf([Standard]=2,"stop",IIf([Standard]=3,"nice")))
But the values in Report are #Error?

What am I doing wrong? Thanks.
 
J

Jerry Whittle

Is Standard a text or number field? If text, you may need to put double
quotes around the 1, 2, and 3.

There's also a possible problem with "Type". It's a reserved word and
shouldn't be used for table or field names. Try "TheType".

For more on reserved words see:
http://support.microsoft.com/kb/286335/
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

rml said:
I'm still getting an #Error for the value? Any more ideas?

I'm putting it on the field line in my query.

Type:
IIf([Standard]=1,"abc",IIf([Standard]=2,"stop",IIf([Standard]=3,"nice","")))

Thanks.

NeonSky via AccessMonster.com said:
I think what Jerry means is that you need to establish a "If then else"
statement. An IIF statement works in a fashion that essentially says "If this
criteria is met then do this, if the criteria is not met then do that (else)".
Your IIF statement is saying "If this criteria is met then do this" three
times, without establishing the "if the criteria is not met then do that
(else)" portion.

If [Standard] only has applicable values of 1, 2, or 3 then you can have your
else statement do nothing and it should work. That last comma followed by the
two quotes fullfills the else portion.

IIf([Standard]=1,"abc",IIf([Standard]=2,"stop",IIf([Standard]=3,"nice","")))
I have a query with three fields. ID, Standard, Report

I'm trying to use the following code in the field line:

Report:
IIf([Standard]=1,"abc",IIf([Standard]=2,"stop",IIf([Standard]=3,"nice")))
But the values in Report are #Error?

What am I doing wrong? Thanks.
 

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