how do i populate form fields

G

Guest

I have a form with a combo box called "comany name". This drop down list,
lists clients names. I would like the address box in the form to populate
with the clients address once the clients name is chosen in the "company
name" combo box. How do I do this?
 
R

Rick B

The "Orders" form in the Northwind database does this. Go take a look at
how it is done there.
 
G

Guest

I feel your pain on this one, I had the same problem myself, but I finally
figured it out. This is what I did...

In Form design mode, add all of your address, city, state, zip, etc. columns
to your combo box using the combo box wizard. Set all of the column widths
except for the column for your customer's name so you only see the customer's
name in the combo box (remember columns start with 0).

Use the AfterUpdate event of the combo box to update the address fieldson
your form.Here's the code...

Private Sub ComboBoxName_AfterUpdate()
Me.Department = ComboBoxName.Column(2)
Me.Address = ComboBoxName.Column(3)
Me.City = ComboBoxName.Column(4)
Me.StateOrProvince = ComboBoxName.Column(5)
Me.PostalCode = ComboBoxName.Column(6)

End Sub

Hope this helps!
 
G

Guest

Thank you VERY much!!

twisted5 said:
I feel your pain on this one, I had the same problem myself, but I finally
figured it out. This is what I did...

In Form design mode, add all of your address, city, state, zip, etc. columns
to your combo box using the combo box wizard. Set all of the column widths
except for the column for your customer's name so you only see the customer's
name in the combo box (remember columns start with 0).

Use the AfterUpdate event of the combo box to update the address fieldson
your form.Here's the code...

Private Sub ComboBoxName_AfterUpdate()
Me.Department = ComboBoxName.Column(2)
Me.Address = ComboBoxName.Column(3)
Me.City = ComboBoxName.Column(4)
Me.StateOrProvince = ComboBoxName.Column(5)
Me.PostalCode = ComboBoxName.Column(6)

End Sub

Hope this helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top