PDA

View Full Version : How do I populate blank fields based on a named field in a combo box on a using vba?



wedd
12-29-2010, 03:11 PM
Hi, I'm trying to auto-populate blank fields on a form based on a combo box with customer names. In other words when the user clicks on a name from the combo box the customer's details will populate the blank boxes with all there details. The customer details are stored on a table and I'm using access 2007. Is this possible to do using vba? What's the code to do this? It's been a while since i've done this.


Thanks for your contributions:friends:

Imdabaum
12-30-2010, 10:00 AM
It's possible with and without VBA.

Inside the textbox type =[cboBoxName].[Column](i) where i is the index of the field in your combobox.

IE If cboName has rowsource SELECT [Last Name] & " " & [First Name] as Name, [Last Name], [First Name], Email, Phone FROM Customers

TextBoxLastName =[cboName].[Column](1)
TextBoxFirstName =[cboName].[Column](2)
TextBoxEmail =[cboName].[Column](3)
TextBoxPhone =[cboName].[Column](4)

Or you can actually write the same code in the afterUpdate event for the cboBox.