Dlookup to insert Address into Form

veraloopy

Registered User.
Local time
Today, 03:26
Joined
Apr 10, 2009
Messages
139
Hi :):):)

I'm trying to use dlookup to find a suplliers address from the table "tblSuppliers" and insert it into the corresponding address fields in a form "frmPurchaseOrders"

So far, I just keep getting "#Name?" in the "address1" field

I'm not sure if i'm putting the dlookup in the correct place, I've tried adding it in 'after update' on the suppliers name field and also using it as the control source for the address line 1 field but keep getting the same results.

I have the field 'SupplierName' which is a combo box where the user can scroll down and find the correct supplier name. What I would like access to do, is when the correct name has been found, it auto populates the address lines and telephone number into the form to save them having to type it all out each time.

I've got the combobox "Combo52" with suppliers names working ok and have the following code as the control source on 'SupAddress1'

DLookup ("[SupAddress1]", tblSuppliers, [SupAddress1] & Me!Combo52)

Any suggestions?

Many thanks in advance! :-)
 
Your combo box should be bound the the suppiler table's Primary Key field, which is not the name, even though this is what is displayed to the user.

I would use the after update event of the combo box with a DLookup something like this:

Code:
Me.txtSuppAddress1 = DLookup ("[SupAddress1]", "tblSuppliers" , "[SuppliersID]  =  " & & Me.Combo52)
 
You're stuttering, Boyd! Need to drop one of those ampersands before the Me.Combo52!

& & Me.Combo52

or the Access Gnomes will talk back to you! :D
 
Absolutely brilliant!! that works a treat :-)

Thank you, thank you, thank you !!!! :-)
 
You're stuttering, Boyd! Need to drop one of those ampersands before the Me.Combo52!

& & Me.Combo52

or the Access Gnomes will talk back to you! :D

Thanks for catching the typo!

Darn keyboard ... :D
 

Users who are viewing this thread

Back
Top Bottom