Using IIF to open a form?

  • Thread starter JoeG via AccessMonster.com
  • Start date
J

JoeG via AccessMonster.com

I have a query that looks for a customer number based on a card reader swipe -


IF the query returns a null, customer not found THEN, I want to open a "add
new customer" form, ELSE open "new transaction form".

Can the conditional IIF be used to open a form rather than return a message
or is something more complex needed?

Thanks
 
K

Klatuu

Sure. However, I would use a DLookup rather than a Query to get one record:

Docmd.Openform IIf(IsNull(DLookup("[CUST_NO]","tblCustomer","[CUST_NO] = '"
& <???> & "'"), "AddForm", "TransActionForm")

the <???> would be whereever the customer number you want to look for is.
Also, the above is "air code", so may not be syntactically correct, but this
should give you a good idea.

If you use a query, then you have to establish a recordset, test for number
of records, and destroy the recordset. More code, less efficient.
 

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