Syntax Error?!?! (IIF)

  • Thread starter Thread starter grep
  • Start date Start date
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!
 
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
 
Or, more simply,

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

or

SupplierLookup.TabStop= Not IsNull(SupplierName)
 
Back
Top