Set default value to combo box

jibb

Registered User.
Local time
Today, 02:54
Joined
Dec 1, 2011
Messages
93
I have got a combo box which I type a product code into and then text boxes which display the spec of that product. Is there any way I can set the default value of the text boxes to be a column in the combo box (eg [combo40].[column](1) ). I want to do this so it pulls brings up the default spec of the product but can be edited and saved on another table.

Any ideas?
 
In the after update event of the combo box:
Code:
me.txtcontrol1=me.combo40.column(1)
me.txtcontrol2=me.combo40.column(2)
etc.
 
You can use VBA code in the After Update event of the combo box to read the values from any column available in the combo box and place that value in the appropriate textbox.

If you have a combo box named "cboProducts" and you have three columns available in your combo box, and you want to write the value from the third column, which is the Color value, to a text box named "txtProductColor", you can use code like the code below:
Code:
Me.txtProductColor =  Me.cboProducts.column(2)
Note that the reference for the value from the combo box to put the value from column 3 of the combo box is (2). This is because combo and list boxes use zero based column numbering.

I am assuming that your text boxes are bound to data. If not, you will have to set focus to the unbound text boxes before you can write to them.
 
Brilliant!

Only thing is I can't edit the value that is returned to the text box - it just says it isn't valid for the field...

Thanks for your help
 
All sorted - that text box wasn't bound yet...:o
 

Users who are viewing this thread

Back
Top Bottom