[Field1]/[Field2]+[Field3]*1000. If Field2 or Field3 are empty i got Error Divided by Zero in Query.
In Field4 i want the answer. How will i use the Iif statement?
[Field1]/[Field2]+[Field3]*1000. If Field2 or Field3 are empty i got Error Divided by Zero in Query.
In Field4 i want the answer. How will i use the Iif statement?
Maybe:
Code:IIF(NZ([Field2],0) = 0, 0, NZ([Field1])/[Field2] + NZ([Field3],0) *1000)
Edit: I changed my answer to match Ajax. His answer was better than mine.
iif(isnull(field2),0,nz([Field1])/[Field2]+nz([Field3])*1000)
Not sure this would work but you might try:Code:Nz([Field1],0)/Nz([Field2],0)+Nz([Field3],0)*1000.
If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
Bob Fitzpatrick
If field is Null the return should be Null and no error. So why is there division by 0?
Bob, to prevent division by zero the alternative value from Nz() in denominator would have to be 1, not 0.
Algebraic order of operations apply - the division and multiplication will take place before the addition unless you use parens.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Nope, it´s not working. Now error, You have left out operand or operator
I don't see anything wrong with examples. Post your actual attempted expression.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
IIF(NZ([SummaV],0) = 0, 0, NZ([SummaFel])/[SummaV] + NZ([Summa1],0) *1000)
That looks good.
Post the entire SQL statement or provide db for analysis. Follow instructions at bottom of my post.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Maybe:
IIF(NZ([SummaV],0) = 0, 0, NZ([SummaFel],0))/[SummaV] + NZ([Summa1],0) *1000)
I am guessing OOM means IIf.
Not seeing anything that looks like IsNull() or Nz() function.
The examples given are quite explicit. Just need to follow one.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Tried Everything but nothing works
Looks like missing ) for the first Nz() and one after 1000 although looks some kind of character in those places.
OOM(Nz([SummaV],0) = 0, 0, Nz([SummaFel],0)/[SummaV] + Nz([Summa1],0) * 1000)
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.