IIf syntax help....

  • Thread starter cormier35 via AccessMonster.com
  • Start date
C

cormier35 via AccessMonster.com

x: IIf(IsNull(Equipment!x),[Equipment Compartments]!x,Equipment!x)

I can't say I really understand when to use the [ vs( and the ! confuses me
too??? Help.
Equipment Compartments contains default value if the x value in Equipment
record is null.
 
C

cormier35 via AccessMonster.com

x: IIf(IsNull([Equipment]![x]),[Equipment Compartments]![x],[Equipment]![x])
....this is what I have...first post dropped the brackets for some reason...
sorry
x: IIf(IsNull(Equipment!x),[Equipment Compartments]!x,Equipment!x)

I can't say I really understand when to use the [ vs( and the ! confuses me
too??? Help.
Equipment Compartments contains default value if the x value in Equipment
record is null.
 
D

Dale Fye

Regarding [ ] vs ()

Functions which accept parameters require that those parameters be
incapsulated in parenthesis ( ).

On the other hand, Fields and form objects generally encapsulated in
brackets [ ], and must be encapsulated in brackets if the form name, field
name, or table name contains a space (it's best not to do this).

I'm assuming that this is in a query, but since you don't provide any
additional information, it is hard to tell. Assuming that you have the
[Equipment] table in the query grid, then in order to get the default value
for "X", if there isn't one in [Equipment].X, then it is easier to use the NZ
function. This function only requires two parameters, the first is the field
or value you want to check for Null. The second is the value you want to use
if the first is NULL. To rewrite what you have, it might look like:

X: NZ([Equipment].X, [Equipment Compartments].X)

But this will only work if the table (or query) [Equipment Compartments] is
contained in the FROM clause of the query.

If this doesn't solve your problem, copy the entire SQL string of your query
and post back.
 
Top