Access 2000 DLookUp not functioning in a Form

G

Guest

There is a Staff Table that is connected to a List Box on the Customer Form,
but when I select the command button that uses the the current record to
connect that record of information to print a letter, I can only get it to
look at the Staff table, but it will select the first person to complete the
signature line.
=DLookUp("[Staff]","[Staff Table]") & ", " & DLookUp("[Title]","[Staff Table]"
It won't change the staff person based on the selection done in the list box
on the main form to the command button form to populate the letter. The
command button will fill in the name, address, etc of the current record in
the form letter, but it won't look at the Staff table to populate the letter
with the correct staff person.
 
S

Steve Schapel

Traci,

It's not look at the selected record because you haven't told it to.
Your DLookup expressions do not include a Where Condition clause, so it
just uses the first record it finds which matches your function.
Probably you would need something like this...
=DLookUp("[Staff]","Staff
Table","[StaffID]=[Forms]![Customers]![YourListBox]")
(This assumes the Bound Column of the listbox is the ID field).

But the use of DLookup here is probably unnecessarily complicated
anyway. Is the letter data based on a query? If so, you could just
reference the listbox in the query's criteria. Otherwise, you could
simply reference the listbox's value directly, probably somethink like
this...
=[Forms]![Customers]![YourListbox].[Column](1)

If you need more explicit help, please post back with details of the Row
Source of the listbox, the query that the letter is merging from, and
how and where you are using the DLookup expression you showed us. Thanks.
 

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