populate text boxes bsaed on combo box

  • Thread starter Thread starter Brad Reichert
  • Start date Start date
B

Brad Reichert

I've posted this before but thought I'd try and explain it a bit better.

I've got a form that has controls to 2 tables. The PC table which contains
PC inventory info. PC serial model, CPU, Memory, etc. The other field is
the PC Models table which contains the default values for each specific PC
model. When a PC is model is selected in the combo box, I'd like the text
boxes (linked to the PC table) to be populated based on the default values
in the PC models table. Can this be done and how? I'm an access newbie.

Thanks,

Brad
 
Brad Reichert said:
I've posted this before but thought I'd try and explain it a bit better.

I've got a form that has controls to 2 tables. The PC table which contains
PC inventory info. PC serial model, CPU, Memory, etc. The other field is
the PC Models table which contains the default values for each specific PC
model. When a PC is model is selected in the combo box, I'd like the text
boxes (linked to the PC table) to be populated based on the default values
in the PC models table. Can this be done and how? I'm an access newbie.

Include all of the additional data in your ComboBox as additional columns(they can be
hidden if you like). Then in the AfterUpdate event of the ComboBox run code similar
to...

Me!CPU = Me!ModelComboBox.Column(1)
Me!Memory = Me!ModelComboBox.Column(2)
etc..

The column numbering is zero-based so Column(0) is the left-most, followed by
Column(1), etc..
 
Rick Brandt said:
Include all of the additional data in your ComboBox as additional columns(they can be
hidden if you like). Then in the AfterUpdate event of the ComboBox run code similar
to...

Me!CPU = Me!ModelComboBox.Column(1)
Me!Memory = Me!ModelComboBox.Column(2)
etc..

The column numbering is zero-based so Column(0) is the left-most, followed by
Column(1), etc..

Ok, so in the combo box I include model, CPU, Memory, etc from the PC Models
(defaults) table. Then I enter that code in the afterupdate field where CPU
is the text box containing CPU info in he PCs (inventory) table and where
ModelComboBox is the name of the combo box we are coding. Is that all
right?

Thanks,

Brad
 
Brad Reichert said:
Ok, so in the combo box I include model, CPU, Memory, etc from the PC Models
(defaults) table. Then I enter that code in the afterupdate field where CPU
is the text box containing CPU info in he PCs (inventory) table and where
ModelComboBox is the name of the combo box we are coding. Is that all
right?

Well, you're right except for the AfterUpdate "field" bit.

You go to that event property and press on the build button to the right, choose
"Code Builder" from the choices, and then enter the code into the resulting Code
Module window.
 
Awesome. That worked...now how do I hide the other values in the combo box?
The only option I see is hide the key field.

Thanks,

Brad
 
Brad Reichert said:
Awesome. That worked...now how do I hide the other values in the combo box?
The only option I see is hide the key field.

Set the ColumnWidths property. The widths are separated in the box by
semicolons. Just use zero for the columns you don't want to see.

1.25";0";0";0"
 
Ok. I can get everything to work as long as there are no spaces in the
names. Here is what I have:
Private Sub PCModels_AfterUpdate()
Me!CPU = Me!PCModels.Column(1)
Me!Memory = Me!PCModels.Column(2)
Me!Hard_Drive = Me!PCModels.Column(3)
Me!Sound_Card = Me!PCModels.Column(4)
Me!Video_Card = Me!PCModels.Column(5)
Me!CDROM = Me!PCModels.Column(6)
Me!CDRW = Me!PCModels.Column(7)
End Sub

Columns 3, 4, and 5 don't work. How can I get them to work?

Thanks,

Brad
 
Back
Top