Combining multiple IIf with Nz and DLookup

  • Thread starter P-chu via AccessMonster.com
  • Start date
P

P-chu via AccessMonster.com

Would someone mind taking a look to seek what order my code should be in.
It's not working. Right now it is in the control source of field
"associatedname", but I'm thinking it needs to be somewhere else like on
change, enter, before or after....maybe not.

Two table involved:
Table1
Table2

=IIf(Nz([numberfield],0)=0,"",DLookUp("[associatedname]","[table1]","
[numberfield] = " & [num_field]) where [city]="Orlando".

Then I also need a continuing if statement to add another city for
Tallahassee that is pulled from table2, but the rest of the fields are the
same. Not sure how to proceed, or if I am looking at this totally wrong. My
goal is to pull in the associated name from the appropriate table when the
city field is listed as Orlando or Tallehassee.

Thanks in advance.
 
K

Klatuu

First, you syntax is incorrect.
The Where doesn't belong there at all unless [city] is a field in [table1]
If Orlando is a city in table1 and Tallehassee is in table2, you have bigger
problems than this code, you have a serious database design flaw that will
cause you a lot of grief.
For the moment, I will assume [ctiy] is a field in table1 and you can expect
to find either Orlando or Tallehassee in that field.

=IIf(Nz([numberfield],0)=0,"",DLookUp("[associatedname]","[table1]","
[numberfield] = " & [num_field]) "AND [city] IN("Orlando", "Tallehassee"))
 

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