mrong
asked on
IF stmt in asp loop
Greeting,
I have the followings in asp. How to display objRec8("Amount") as negative number if objRec8("CreditDebit")='C' ?
Do While Not objRec8.EOF
Response.Write _
"<TR ALIGN=CENTER BGCOLOR=ivory>" & _
"<TD>" & objRec8("CreditDebit") & "</TD>" & _
"<TD align=right>" & FormatCurrency(objRec8("Am ount"),2,- 1,0) & "</TD>" & _
"</TR>"
objRec8.MoveNext
Loop
Thanks in advance.
I have the followings in asp. How to display objRec8("Amount") as negative number if objRec8("CreditDebit")='C'
Do While Not objRec8.EOF
Response.Write _
"<TR ALIGN=CENTER BGCOLOR=ivory>" & _
"<TD>" & objRec8("CreditDebit") & "</TD>" & _
"<TD align=right>" & FormatCurrency(objRec8("Am
"</TR>"
objRec8.MoveNext
Loop
Thanks in advance.
ASKER
tried the following but gave me error
"<TD align=right>" & FormatCurrency(iif(objRec8 ("CreditDe bit")='C', objRec8("A mount")*-1 ,objRec8(" Amount")), 2,-1,0) & "</TD>" & _
"<TD align=right>" & FormatCurrency(iif(objRec8
ASKER
Microsoft VBScript compilation error '800a03ea'
Syntax error
"<TD align=right>" & FormatCurrency(iif(objRec8 ("CreditDe bit")='C', objRec8("A mount")*-1 ,objRec8(" Amount")), 2,-1,0) & "</TD>" & _
-------------------------- ---------- ---------- ---------- -------^
Syntax error
"<TD align=right>" & FormatCurrency(iif(objRec8
--------------------------
I don't have access to vbscript right now to post a 100% working example.
IIF should be what you need. You will need to take the syntax for it and apply it to your requirements.
I would start with just getting it to display correctly just with IIF. Then add formatting with FormatCurrency until you find what is causing the error.
You might need to CAST objRec8("Amount") as a number before doing the multiplication.
IIF should be what you need. You will need to take the syntax for it and apply it to your requirements.
I would start with just getting it to display correctly just with IIF. Then add formatting with FormatCurrency until you find what is causing the error.
You might need to CAST objRec8("Amount") as a number before doing the multiplication.
ASKER
I need the correct asp syntax.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Untested but something like:
iif(objRec8("CreditDebit")
http://support.microsoft.com/kb/219271