How to get result of an AutoLookup Query into a Form/Table

E

Elizabeth

Access Help says you can create an "AutolookUp query" that
will automatically fill in field values for a new record
in a form, report or table. Although there isn't an option
for creating an Autolookup query in the Create New Query
dialog, I did manage to figure out how to do it and it
works fine while working directly in the table. However,
Help doesn't provide any instruction on how to get
the "Autolookup" to work in a form!

Here's what I've got:

Table1:
CoID
CoName
ContactFirst
ContactLast
Phone

Table2:
CoID
Contact

The two tables are joined on CoID.

In an Orders form, I want a user to pick a company name
(CoName) from a combo box called Company this works fine).
Based on the CoName the user selects, I want the form to
display the contact's name as a string ("ContactLast"
& ", " & ContactFirst)in an unbound box called Contact. In
another box I want the contact's phone number to display.

In another similar situation I'd like to actually store
the data in a table field.

I suspect an expression is in order, but don't know how to
write it or where to put it. Can someone enlighten me?

Elizabeth
 
F

fofa

best way to do this is on the OnClick event of your combobox (so it
happens when they select the company), create a procedure and populate
the form fields using some dlookup's

Me.ContactName = dlookup("ContactLast","Table1","CoName = '" &
Me.Company & "'") & ", " & dlookup("ContactFirst","Table1","CoName = '"
& Me.Company & "'")

as an example
 

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