Skip to main content
Answer

IIF statement returning a syntax error

  • August 21, 2025
  • 7 replies
  • 77 views

I am trying to make credit memo numbers return a negative amount and leave the all other doc types positive. This is the code I wrote and I cannot figure out how to get this to work correctly. Any help is appreciated.

 

=IIf([ARInvoice.DocType]='Credit Memo',(IIf([ARTaxTran.CuryTaxableAmt]<>Null Or [ARTaxTran.CuryTaxableAmt]<>0,-([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt]),0))),(IIf([ARTaxTran.CuryTaxableAmt]<>Null Or [ARTaxTran.CuryTaxableAmt]<>0,([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt]),0))

 

Best answer by DrewNisley

@jlindsey It is because of the DocType part of your IIf statement. It should actually be ‘CRM’ not ‘Credit Memo’. That is how it is saved in the database. Here’s the list of how they’re saved.

 

7 replies

darylbowman
Captain II
Forum|alt.badge.img+15

Try this:

IIf(IsNull([ARTaxTran.CuryTaxableAmt],0)<>0,([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt])*IIf([ARInvoice.DocType]='Credit Memo',-1,1),0)

 


  • Author
  • Freshman I
  • August 21, 2025

Try this:

IIf(IsNull([ARTaxTran.CuryTaxableAmt],0)<>0,([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt])*IIf([ARInvoice.DocType]='Credit Memo',-1,1),0)

 

This throws up a lot of errors. I’m not at my desk right now but I can add a picture of all the errors popping up. 


  • Author
  • Freshman I
  • August 21, 2025

So I figured out that I was missing some parentheses in one area and had too many in another. BUT the value will not show up as negative no matter how I format it. I have tried *-1, (-1), -, -(formula)…

=IIf([ARInvoice.DocType]='Credit Memo',(IIf([ARTaxTran.CuryTaxableAmt]<>Null Or [ARTaxTran.CuryTaxableAmt]<>0,-([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt]),0)),(IIf([ARTaxTran.CuryTaxableAmt]<>Null Or [ARTaxTran.CuryTaxableAmt]<>0,([ARInvoice.CuryDetailExtPriceTotal]-[ARTaxTran.CuryTaxableAmt]),0)))


DrewNisley
Pro I
Forum|alt.badge.img+3
  • Pro I
  • Answer
  • August 22, 2025

@jlindsey It is because of the DocType part of your IIf statement. It should actually be ‘CRM’ not ‘Credit Memo’. That is how it is saved in the database. Here’s the list of how they’re saved.

 


darylbowman
Captain II
Forum|alt.badge.img+15

​...It should actually be ‘CRM’ not ‘Credit Memo’

Oh boy. How did I miss that.


DrewNisley
Pro I
Forum|alt.badge.img+3
  • Pro I
  • August 22, 2025

Oh boy. How did I miss that.

Hehe, happens to the best of us 😄


JSpikowski
Jr Varsity II
Forum|alt.badge.img
  • Jr Varsity II
  • August 22, 2025

Typos and assumptions are are programmers greatest foe.