View Full Version : Problem with IIf statement.


Fuga
04-12-2002, 08:58 AM
I have a calculated field in a query.

Calcfld: (([field2]/[field1])*100)

In order to avoid error I use the following statement in the criteria:

IIf(IsNull([Field1]);"0";([calcfld]))

I think this should mean "If field1 is null, then return 0 to calcfld, otherwise return the calcfld value".

The problem is I get an overflow. How should I write the criteria to do the trick?

Fuga.

David R
04-12-2002, 09:06 AM
Criteria would be the wrong place for this because the value has already been calculated. Try this as your field
Calcfld: IIf((IsNull([Field1]) Or [Field1]=0),0,([Field2]/[Field1])*100))

Fuga
04-13-2002, 07:17 AM
Thanks David R!

The query is now working. However, I would like to represent it graphically, but when I use the graph wizard, itīs not working at all.

When I create a graph without the wizard I get a message that one of the fields contains an invalid data type.

Since there are only two fields, one of which is a date field, I guess the problem lies in the calcfld.

Is the field really invalid?

How do I solve the problem?

I guess I could do a make table query, but is that really the correct way to go about it?

Fuga.