DLookup Errors

G

Guest

Hi
I'm trying to build a form which can be used just like an invoice form.

I'd like the Shipping Address fields to use the Billing Address fields as
default values, e.g. Billing Address Line 1 might be, say, 221b Baker Street,
so the default value for Shipping Address Line 1 would be 221b Baker Street.

I'm trying to use a DLookup function to achieve this. This is the line I put
into the default value field of the Shipping Address Line 1 properties:

=DLookUp("[Address Line 1]","Customers","[CustomerID]=Form![CustomerID]")

I think this says "look up the value in the Address Line 1 field of the
Customers table where the Customer ID matches the Customer ID currently on
the form".

It does n't work. What am I doing wrong?
 
J

John Spencer

First thing is that default's are only filled for new records. I would
expect that customerID is null on a new record.

Second your DLookup needs to look more like the following (assumption
CustomerID is a text field)

DLookUp("[Address Line 1]","Customers","[CustomerID]='" &
Forms![NameOfTheForm]![CustomerID] & "'")
You could use that in the after update event of the CustomerID control (or
other control) to assign a value to the Address control.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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