PDA

View Full Version : Combobox Question



Hopeless
07-26-2004, 02:04 PM
I have a 2 column combobox on an Access form that gets its values from two fields: ID and Name. The first column (ID) has a 0" width and is not visible when the form is displayed.

How do I set the value of the combobox to be equal to a specific ID number? In other words, how can I display a specifc name in the combobox by referencing its hidden ID number.



Thanks

ALaRiva
07-26-2004, 02:23 PM
I have a 2 column combobox on an Access form that gets its values from two fields: ID and Name. The first column (ID) has a 0" width and is not visible when the form is displayed.

How do I set the value of the combobox to be equal to a specific ID number? In other words, how can I display a specifc name in the combobox by referencing its hidden ID number.



Thanks
Check the Bound Column of your Combo Box (in the properties of the combo box). If it's 1, then you are bound to your ID Column, which is good.

So then, what you can do to set the combo box to a specific ID is something like this:


Me.YourComboBoxName = 3

Where 3 is the actual ID you want to set it to.

Now, let's say you wanna reference the textual value from the second column, then you can do something like this.

Msgbox Me.YourComboBoxName.Column(1)

Combo Box Columns are zero-based so 1 would actually be the physical column 2.

HTH, Thanks.