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!

Look up on a Form

Status
Not open for further replies.

melisc

Programmer
Feb 6, 2004
15
US
I am trying to set up an Access form so that the item selected in the combo box populates the rest of the fields on that form. I want to use it as a lookup box so that when someone selects a Company, the company information will populate in the rest of the fields. Any ideas?
 
Use an after update event for the list box. Here is code I use for the same thing on a sales order form.

ChaZ

Private Sub CustomerNumber_AfterUpdate()
Forms!so_head!Name = DLookup("CustomerName", "Customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!Address1 = DLookup("Addressline1", "Customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!Address2 = DLookup("Addressline2", "Customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!City = DLookup("City", "Customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!State = DLookup("state", "customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!Zip = DLookup("Zipcode", "customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!Contact = DLookup("Contact", "customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!Phone = DLookup("Phone", "customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")

Forms!so_head!ShipName = DLookup("ShipName", "Customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!ShipAd1 = DLookup("Ship1", "Customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!ShipAd2 = DLookup("Ship2", "Customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!ShipCity = DLookup("ShipCity", "Customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!ShipState = DLookup("Shipstate", "customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!ShipZip = DLookup("ShipZip", "customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!ShipContact = DLookup("ShipContact", "customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
Forms!so_head!ShipPhone = DLookup("ShipPhone", "customer", "Customernumber='" & Trim(Forms!so_head!CustomerNumber) & "'")
End Sub


Ascii dumb question, get a dumb Ansi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top