Combo box - > label

Mer12

New member
Local time
Today, 10:46
Joined
May 30, 2011
Messages
2
I'm a beginner at Access and I stumbled upon a problem. Can someone tell me how to Link Combo box to Label (or text box), so that it writes value from a field (F_info for example) from the same row as selected value from Combo box (F_name for example). Does this go trough After Update on Combo box and where to write it in Code or Expression builder.
 
Welcome to AWF,

you want to give the combo box value to the textbox (field) on your form?
you can do this with After Update Event of the combo box:

Private Sub Combo0_AfterUpdate()
textBoxOntheForm.Value = me.Combo0.Value
End Sub

hth
 
You need to be clearer about where the controls you want to use are located.

Is the combo bound to the records or is it unbound?
Is F_info in the records or just another row of an unbound combo.

BTW Khalid:
There is no need to include the Value property in the reference to a control because it is the default property.
 
I think I understand your question but it is vaguely worded so this is a guess as to what you wanted. If your combo box is based on a query or table, you can return more than one value to the combo box at the same time (all from the same row, but different fields.)

So you build your combo box using the control wizard. It will ask you where to get the data. You tell it. It will look at the table/query and give you a list of values it could return for you. You identify what you want. Let's say for the sake of argument, you have two values. One for the combo box and one for the text box. Let's further say that this combo-box is set for single-select, not multi-select. That is, you can only select one row at a time.

So now you select the row. Inside the combo box, you have TWO columns (because we said that you were going to ask for two values from the same record.) Columns are zero-based for Combo Boxes. The selected item is visible in the .ListIndex property of the combo box.

Normally, the item that you selected as the first field to be returned is also the one that is visible in the combo box. If the combo box name is CBX, then the item that is visible after you selected something is

CBX.Column(0,CBX.ListIndex)

In the control's Click event or its LostFocus even, you could load the text box (call it TBX) by doing this:

TBX = CBX.Column(1,CBX.ListIndex)

This is a glossy overview. Play with it a bit. Read up on the properties of Combo Boxes before you play with them too much. But this is the main part of what you asked, I think.
 
Sorry guys if i wasn't clear enough.... i will try to explain better this time.
But thanks for help... i will go with this for now.

I have one table and made a from in it ( And inside the form i have one Combo Box and Text Box[on which i would like to put multiline). I used Select Query to get values from a field so that i can select them in Combo Box. In the other Field i have Values which i want them to show in TextBox once i select a value from a Combo Box (example i select job (lets say Dentist) and Text Box shows description for that job from second field).
 
Read my response again. What you said is EXACTLY what I described.
 

Users who are viewing this thread

Back
Top Bottom