Update Textbox based on Selection from Multiple Comboboxes

  • Thread starter Thread starter abalboa
  • Start date Start date
A

abalboa

Hello :)

I have a text box (txtID) and three combo boxes (cmb1, cmb2 & c,b3).
I want the textbox to auto-populate based on the selection made from
the three combo boxes.

If I have one combo box, I would do the following:
assuming the combo box's column number of the field I want stored in
the text box were the first column of the query, then

Private Sub cboName_AfterUpdate()

Me!txtHidden.Value = Me!cboName.Column(0)

Exit Sub

However, how would I write this if its based on three combo boxes???
Help!

Annette
 
On the surface, what you are trying to do would appear to be a bad idea.
The name of your text box (txtID) *seems* to imply that it is some type
of unique identifier (Primary Key, Foreign Key, etc.). Are you trying to use
the values from three different combo boxes to create a unique key of some
type?

How can you be sure that the users will select appropriate values in the
combo boxes, or that they will make a selection at all?

How can you be sure that any potential selections will be made in the
correct order (assuming there is a correct order)?

What you would need to do is build a string based on the combo box
selections, then apply that string to the text box in, for example, the Click
event of a command button or something. Again, I think this approach
will be opening the door to bad data in your application.

Maybe my assumptions are wrong. It may be helpful if you can provide
more info about what you are doing and why.
 
Back
Top