Whats wrong with my if statement

lordnikon

New member
Local time
Today, 08:12
Joined
Jun 23, 2008
Messages
8
iif(Combo57.Column(1)<>0, [Material Surcharge] = Combo57.Column(1))

it keeps giving me the error "Compiler error: expected: ="

http://flickr.com/photos/14540614@N06/2605721246/

i am trying to say if combo box column 1 is not equal to zero make my text box material surcharge equal to it.



Matt


On a side note, the reason that i am doing it this way is because when i do an after update and the data is "$0.00" it clears the box and leaves it blank. So i am trying to make the default value "$0.00" and not updating it if it is 0.
 
I am not sure your approach is the best for this, but no matter, the IIf Statement has 3 parameters and you only have 2.

IIf
(
[Test Case], { Perhaps Combo57.Column(1)<>0 }
Value if [Test Case] is TRUE, { Perhaps [Material Surcharge] = Combo57.Column(1) }
Value if [Test Case] is FALSE { Perhaps [Material Surcharge] }
)
 
Last edited:
I believe that you can use it with only one parameter.
 
Are you putting this in the controlsource of a textbox?
 
I was not aware of this as I have never used it that way or seen it used that way. I cannot be sure what (if any) part of the trouble stems from this variation of the IIf statement, but I suspect it is not the cause. I defer to others to answer this one.
 
If it is code then change it to:

Code:
If Me.Combo57.Column(1) <> 0 Then
   Me![Material Surcharge] = Me.Combo57.Column(1)
End If
 
no its code
the "iif" does not work in code, it only works in the design view of queries and in form controls. if this is code, it would be what Bob posted, though i tend to put in ELSE: END IF instead of just End If, but both work fine.
 

Users who are viewing this thread

Back
Top Bottom