Auto fill fields based on combo box selection

P

Piperlynne

I need help with having a form display the values in certain fields from a
table based on a combo box.
I have a form based on tblProject.
On the form, I have a combo box that looks at the Brand Name field in
tblBrand to find values for user to select to populate the Brand Name in the
tblProject. The combobox is named cboBrand.

In tblBrand - there are 3 fields - UnitType, MasterType, DateCoding that I
want to display when the user selects a Brand Name.
I have tried using cboBrand.Column(1) etc, but I'm pretty sure I'm missing
something.
 
A

Arvin Meyer MVP

The column index is zero (0) based. The 3 field must be included in the
combo box, even if you didn't want to see them, so typically you'd have the
following fields in the combo with their widths set like:

BrandID 0"
BrandName 1.5"
UnitType 0"
MasterType 0"
DateCoding 0"

your column count would be 5

To refer to UnitType, your code in the AfterUpdate event of the combo would
look like:

Me.txtWhatever = Me.cboBrand(2)
 
P

Piperlynne

Great, thanks!
One question.
In the after update piece, would I repeat that string for each textbox I
want filled in?
I can get the first box (Unit) to work right now, but I can't get the others
to fill in.
 
A

Arvin Meyer MVP

Yes. If they are in the order below, Master would look like:

Me.MasterType = Me.cboBrand(3)

and DateCoding:

Me.DateCoding = Me.cboBrand(4)
 

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