Page 1 of 1

Need help with syntax

Posted: Sun Dec 20, 2009 9:35 pm
by John Dykema
I need help with the syntax when writting my custom reports. Seems I'm always screwing up the ifs/ands/or commands. What manual or For Dummies book would you recommend to help me with this language?

For example: my code of-
IIF((status_desc = "Member" ) OR (status_desc = "Inactive member"), "Member", "Not a member")
is always coming back False (Not a member).
I'm not getting any members. What's a better way to state this? It veryifies clean. :wall:

Re: Need help with syntax

Posted: Mon Dec 21, 2009 10:06 am
by Tracy
This is Visual FoxPro. The example you are showing should work, if you've spelled and cased the text correctly. To prevent loss of functionality when someone changes the case of the values you could do this:

Code: Select all

IIF(UPPER(status_desc) = "MEMBER" OR UPPER(status_desc) = "INACTIVE MEMBER", "Member", "Not a member")
If you need to be more exact this syntax would be used (the double equal means they need to exactly match:

Code: Select all

IIF(UPPER(ALLTRIM(status_desc)) == "MEMBER" OR UPPER(ALLTRIM(status_desc)) == "INACTIVE MEMBER", "Member", "Not a member")

Re: Need help with syntax

Posted: Tue Dec 29, 2009 3:04 pm
by John Dykema
Thanks, I used your syntax and now it works fine.