PDA

View Full Version : Access query IIF error


Cheeseboy
08-08-2011, 01:47 AM
Hello,
I am trying to make a truepart false part field. When the monthly fee status field in my table says active,
I want the query to say active, and when the table says on hold, I want the query to say on hold.
I believe this is the right code but i need some help.
When i try to run this query,
Expr1: IIf([Monthly Fee Status],"Active","On Hold")


I get a syntax error "comma"



Does anyone know how i can make this code run?

Thanks

Old Pedant
08-08-2011, 01:59 AM
What is the DATA TYPE of the field???

As you have coded it, it would need to be a BOOLEAN field (also known as a YES/NO field if you look at it with the Access table designer).

Old Pedant
08-08-2011, 02:00 AM
Note that normally you would use apostrophes in the query, not quotes.


IIf([Monthly Fee Status],'Active','On Hold')

but that sill assumes the field is a boolean field.

Cheeseboy
08-08-2011, 03:32 AM
I still get a syntax error. The instructions I have say:

Add a calculated field named Monthly Fee Status as the last column that equals active if the membership field is equal to Active and equals Not Active otherwise.

Old Pedant
08-08-2011, 04:47 AM
So what is the data type of the membership field?

And why would you expect to be able to do an IIF( ) on a field that doesn't exist?

*READ* the instructions:[quote]
Add a calculated field named Monthly Fee Status as the last column
that equals active if the membership field is equal to Active and equals Not Active otherwise.
[quote]
membership is the *EXISTING* field, according to that.


SELECT ..., IIF( membership = 'Active', 'Active', 'Not Active' ) AS [Monthly Fee Status] ...

would be my *guess*. But that's only if membership is indeed some kind of text field.

If you don't know what data types are and mean, time to find out.