how to select from a table and fill in other data in access

R

RobG2007

my problem- i have a table of customer names , addresses , postcodes etc ,
now in my form i have created 1 combo box to select the customer name - this
works fine but once i have selected the name i want to automatically fill in
postcodes addresses that go with that customers name , please someone help
iam going insane haha thankyou--- RG
 
D

Douglas J. Steele

A combo box can have more than one piece of information for each row. This
is done by selecting a RowSource that returns multiple fields.

Once you've done that, in the AfterUpdate event of the combo box, you can
put code that refers to the additional columns (whether or not they're
visible in the combo box), and assign their values to text boxes:

Private Sub MyCombobox_AfterUpdate()

Me!txtAddress = Me!MyCombobox.Column(1)
Me!txtPostCode = Me!MyCombobox.Column(2)

End Sub

This assumes that the address is the 2nd column and the postcode the 3rd
column (the Column collection starts numbering at 0)
 
R

RobG2007

i think i understand what your saying iam quite new to access so forgive my
stupidity but how do i create the source that returns multiple fields ?
 
D

Douglas J. Steele

Set the RowSource for the combo box a query that returns the necessary
fields.

Set the combo box's ColumnCount property appropriately.

To control which columns are visible, use the ColumnWidths property.
 
Top