Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIF nesting

Status
Not open for further replies.

mensud

Programmer
Jul 22, 2001
51
US
Hello,

I am trying to use 6 IIF commands in SetAll method.
It looks like this:

thisform.grid1.SetAll("dynamicbackcolor", ;
"IIF(orderCursor.term='PRE', rgb(128,128,128),;
IIF(orderCursor.term='PEN', RGB(255,128,64),;
IIF(orderCursor.term='PEI', rgb(0,0,255),;
IIF(orderCursor.term='PRO', rgb(255,0,255),;
IIF(orderCursor.salesmat=1, RGB(0,0,0),;
IIF(orderCursor.onhold=.t., RGB(255,0,0),RGB
(255,255,255)))))))","Column")

But I always get a message that there is a syntax error.
I tried a few possibilities and here is what I discovered:
If I am using only 5 IIF commands and "6" closed parenthesis, code is correct, otherwise I get an error. The question: why "6" parenthesis when I use only 5 IIF commands
This code apsolutly does not work with 6 IIF commands.
Any ideas what could cause the problem?

Thanks

Mensud
 
';' is missing because of my mistyping. But actually, there is no missing comas, parenthesis,... in my code.
 
Mesud,

I don't think your statement is too long, but it could be that the second parameter exceeds the limit on the length of a literal string. Try breaking the second parameter (the one with all the IIFs) into separate strings and then add them together.

That said, I agree with Dave S that a UDF would be a better option here.

Mike


Mike Lewis
Edinburgh, Scotland
 
If orderCursor is the current work area, you may get away with taking the alias name out. Although I don't like doing it, sometimes we must in order to reduce the statement size.

Thus:
orderCursor.term

becomes:
term


Jim Osieczonek
Delta Business Group, LLC
 
mensud,
Is your real code broken into lines like this?
Try this:

thisform.grid.SetAll("dynamicbackcolor", ;
"IIF(orderCursor.term='PRE', rgb(128,128,128),"+ ;
"IIF(orderCursor.term='PEN', RGB(255,128,64),"+;
"IIF(orderCursor.term='PEI', rgb(0,0,255),"+;
"IIF(orderCursor.term='PRO', rgb(255,0,255),"+;
"IIF(orderCursor.salesmat=1, RGB(0,0,0),"+;
"IIF(orderCursor.onhold=.t., RGB(255,0,0),RGB(255,255,255)))))))","Column")

It didn't give me syntax error.

Stella
 
The case with UDF is working.
Thanks a lot to everyone.

Mensud
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top