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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FORM & COMBOBOX 2

Status
Not open for further replies.

mercury1

Programmer
Sep 23, 2002
8
US
I have a table with the following fields:
Name,Address ,City, State,Zip

I would like to create a form with a combo box.

When I click on "name" in combo box, "address", "city", "state" & "zip" that match with "name" will appear on form.

Thank you for your help.
 
Create your combobox on the form and name it NameCombo Open the properties of the ComboBox and enter in the Row source the following:
Select Name, Address, City, State, Zip FROM tblYourTable Order By Name;

Set the property Bound Column to 1, Number of Columns to 5, ColumnWidths to 2;0;0;0;0

Create four Text Controls on the form and name them Address, City, State, and Zip.

In the OnGotFocus EventProcedure of the ComboBox put the following VBA code:
me![NameCombo].dropdown

In the AfterUpdate Event Procedure of the ComboBox put the following VBA code:
me![Address] = me![NameCombo].column(1)
me![City] = me![NameCombo].column(2)
me![State] = me![NameCombo].column(3)
me![Zip] = me![NameCombo].column(4)

This should do as you asked. Remember to change the name of the table in the SQL code to the name of your table.
Bob Scriver
 
You can also do this from the combo box wizard also. Put a combo box on the form and when the first window comes up, select the third option (find a record on my form based on the value selected). On the next window select the items you want the combo box to select, when you are done put each item on the form as a text box and the combo box will fill them in. Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top