Syntax Error?!?! (IIF)

G

grep

Okay, now here's my understanding of the IIF statement:

Evaluate a boolean expression.
If the expression = True, do the first thing.
If the expression = False, do the second thing.

Now, this code is placed in OnCurrent for the form. Basically, the
intent is that a field should be skipped for a new record. Why am I
getting a syntax error?

iif (isnull(SupplierName), SupplierLookup.TabStop=False,
supplierlookup.TabStop=True)

TIA!
 
R

Rick Brandt

grep said:
Okay, now here's my understanding of the IIF statement:

Evaluate a boolean expression.
If the expression = True, do the first thing.
If the expression = False, do the second thing.

Your close, but it's actually more like...

Evaluate a boolean expression.
If the expression = True, return the first value
If the expression = False, return the second value

IOW IIf() is used to return values, not execute statements. The good news is
that in code there is no reason to use IIf(). Just use an If-Then block
instead.

If isnull(SupplierName) Then
SupplierLookup.TabStop=False
Else
Supplierlookup.TabStop=True
End If
 
D

Douglas J. Steele

Or, more simply,

SupplierLookup.TabStop= (IsNull(SupplierName) = False)

or

SupplierLookup.TabStop= Not IsNull(SupplierName)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top