if table1.field1 is empty, table2.field1, table1.field1 in form

  • Thread starter ricardozelaya via AccessMonster.com
  • Start date
R

ricardozelaya via AccessMonster.com

I'm trying to select where to get the data from in a form. I have two tables,
one or both of them contain the information. I want the form to be filled
with data from table 1, but if table 1 does not contain data, I want to get
it from table 2. I put the following in the control source:
=IIF(table1.field1=null, table2.field1, table1.field1)

How am I supposed to write that expression?

Thanks
 
D

Douglas J Steele

You cannot use = in conjunction with Null: you must use the IsNull function:

=IIF(IsNull(table1.field1), table2.field1, table1.field1)

Another, perhaps simpler, alternative is:

=Nz(table1.field1, table2.field1)
 

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