Populate other fields from a combo box

harrisw

Registered User.
Local time
Today, 22:49
Joined
Mar 27, 2001
Messages
131
I have a combo box which gets its data from a query.

How can I populate other fields on the form based on the users selection in the combo box.?
 
The combo box must have all the fields which you want to populate in forms fields. Display the value you want to show in combo box and hide the other fields. Then in the AfterUpdate event of the combo box write the below script for each field.

formfield1 = form.comboboxcontrol.column(column number)

Ex: Combo box has customer information, like
customer name, add1, city, state, zip. The combo box name is "CMBCUSTOMER".

You want to show customer name in the combo box for selection, hide the other columns.
Then the script will be

Me.name = Me.cmbcustomer.column(0)
Me.add1 = Me.cmbcustomer.column(1)
Me.city = Me.cmbcustomer.column(2)
and so on. The column index will always start from 0.

I think this will help you.
 
If your forms Record Source is linked to a table or query and the combo is linked to a field in that table or query then you can use it so show the related fields from the same record. Send me an email if you want a sample.
 
More questions -
I tried and this didn't work for me.
1. the form I am creating has a combo box created from another table. When I try to enter data it tells me I have a macro error. I don't have any macros unless the after event entry is considered a macro.

2. Per someone elses suggestion I put the after event in each corresponding field rather than in the combo box after event. With that it puts the correct info in but I lose it when I go to enter a new record.

Not sure what I am doing wrong but would really appreciate someone's help.

Thanks,
Rita
 

Users who are viewing this thread

Back
Top Bottom