Help with DlookUp - I cant get this to work

G

Guest

I’m trying to have the data from one field fill a second field automatically.
For instance:

Customer Number : 1234

Auto entry - Name of Customer

I’m not sure if this is the right code to use of if there is something easier.

Thanks

Kevin Sebring
 
J

John Vinson

On Tue, 28 Sep 2004 16:45:04 -0700, "Kevin Sebring" <Kevin
I’m trying to have the data from one field fill a second field automatically.
For instance:

Customer Number : 1234

Auto entry - Name of Customer

I’m not sure if this is the right code to use of if there is something easier.

The simplest way is - DON'T DO IT AT ALL.

If you're trying to copy the customer name from the Customer table
into another table, it is neither necessary nor a good idea to do so.
Store the customer number, and *only* the customer number.

If you just want to display (not store) the customer name, there's a
couple of possibilities: one would be to set the Control Source of a
textbox to

=DLookUp("[Customer Name]", "[Customers]", "[Customer Number] = " &
[txtCustomerNumber])

using of course your own field and control names.

Better, use a Combo Box based on the Customer table to update the
Customer Number. Include both the number and the name in the combo's
rowsource query; set the Control Source of a second textbox to

=cboCustomer.Column(1)

where cboCustomer is the name of the combo box, and (1) means the
*second* field in the combo's row source query - it's zero based.

If you need to see the name in conjunction with the customer number on
a Report, it is not necessary to include the name in the second table;
instead, base the Report on a query joining the second table to the
Customer table.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

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