Iif expreesion

Janjang

Registered User.
Local time
Today, 22:17
Joined
Oct 17, 2005
Messages
80
how to make calculation in form accept null value when using Iif in query?


like this

Code:
Extra1: Iif([company]=-1,50)

i use company as check box.. when i check it, 50 appear at texbox at form..then i click at calculate button (to calculate quotation) have no prob... but when check box not checked, is say error..

Run-time error '64'
Invalid use of null

what should i do?

is my Iif expression is correct?
 
Firstly, why not do the calculation in the Form? The ControlSource would be something like you have already:
Code:
=IIf([company]=-1,"50")
If you don't want the text box to show anything just set the FalsePart to a space or something:
Code:
=IIf([company]=-1,"50", " ")

Bobadopolis
 
Ignore this if I'm wrong but I thought the problem was that if Extra1 was null then the calculation failed, and thus the calculation needs to check for Null something like If IsNull([Extra1]) Then...........

Brian
 
You make a good point Brian!

And actually, if your using the text box to make calculations wouldn't you have to return a zero in the FalsePart? The character would have to be numeric for the calculation to work!(?)
 

Users who are viewing this thread

Back
Top Bottom