Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dlookup help please

Status
Not open for further replies.

jon182

Technical User
Feb 7, 2002
18
GB
i have the following tables with customer details filled, address, county, town, and post code.

I would like to use the dlookup function in a form so that when the post code is entered the town, county and address are automatically filled thus avoiding errors.

The tables are all linked correctly

Jon
 
Hi Jon

Is it your intention to populate the customer address details fields in the customer table or just to display the full address on the form(this may take some time when your moving from record to record)?

I am asuming you have a table with every post code in it?

Once I know what you are after I should be able to give you some code.

Cheers

Chris
 
Jon,

This is 3+ DLookups.

It would therefore be quicker to do using a recordset.

Something like this is the post code after update event....

Private Sub txtPostcode_AfterUpdate()

Dim db As Database
Dim rst As Recordset

Set db = CurrentDB
Set rst = db.OpenRecordset("SELECT * FROM PostcodeTable WHERE PostCode = '" & txtPostcode & "'")

txtAddress1 = rst!Address1
txtAddress2 = rst!Address2
txtAddress3 = rst!Address3
txtTown = rst!Town
txtCounty = rst!County

End Sub

But.....quick point......

Your post suggests you've got the tables normalised incorrectly. If you've got a table with the post codes.....then all you need to store is the house number or house name and the post code.

Craig
 
Hi thanks for replys

I have a table with post codes in it, once the post code is selected i would like to display the full address on the form

Jon
 
Yep....

That's no problem.....

The full address (minus house number) should be stored in the postcode table....

The display should be done via a query....but there's no need to store the data twice....

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top