how do i populate form fields

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
The "Orders" form in the Northwind database does this. Go take a look at
how it is done there.
 
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!
 
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!
 
Back
Top