Populate a text box based on the selection of a combo box.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I can't figure out how to populate a text box based on the selection of a
combo box in Access.

I have a form called "Evaluations" a combo box on that form lists the
available tasks. What I would like to do is populate a text box at the
bottom of the form labeled "Wage" with the corresponding wage to that task
and I can't figure out how to.

Anyhelp is greatly appreciated.

With Respect,

Christopher Gagnon
 
1. Ensure that the combo box (cboTask) contains 2 fields: Task & Wage
2. Ensure that Column Count of the combo box set to 2
3. Ensure the Column Widths is 1":0"
4. Ensure Bound Column is set to 1
5. In the After Update event of cboTask insert the following:

Private Sub cboTask_AfterUpdate()
Me!txtWage = Me!cboTask.Column(1)
End Sub

6. Insert a text box in the form (txtWage)
7. Save the form and run it.

Hope this is helpful.
 
If the Wage field is not bounded to the table, and you just use it to display
the wage without storing it, then in the control source of the Wage Field you
can write
=[cboTask].Column(1)

And there is no need for code to be written
Assuming that the wage is the second column in the rowsource of the combo.
The count of the column start from 0.
 
The text field will be used just to display the results not store them. How
do you tell what column wage is in the combo box?


Ofer said:
If the Wage field is not bounded to the table, and you just use it to display
the wage without storing it, then in the control source of the Wage Field you
can write
=[cboTask].Column(1)

And there is no need for code to be written
Assuming that the wage is the second column in the rowsource of the combo.
The count of the column start from 0.


--
I hope that helped
Good luck


Itman79 said:
I can't figure out how to populate a text box based on the selection of a
combo box in Access.

I have a form called "Evaluations" a combo box on that form lists the
available tasks. What I would like to do is populate a text box at the
bottom of the form labeled "Wage" with the corresponding wage to that task
and I can't figure out how to.

Anyhelp is greatly appreciated.

With Respect,

Christopher Gagnon
 
Open the form in design view
Look at the row source property of the combo box,
Check the location of the Wage in the select statement

Select Field1,Field2,Field3,Field4 From TableName

Field1 = column(0) or none will bring default 0
Field2 = column(1)
Field3 = column(2)
Field4 = column(3)

So if the SQL will be
Select Field1, Wage From TableName

In the ControlSource of the Text Field you can write
=[ComboName].column(1)



--
I hope that helped
Good luck


Itman79 said:
The text field will be used just to display the results not store them. How
do you tell what column wage is in the combo box?


Ofer said:
If the Wage field is not bounded to the table, and you just use it to display
the wage without storing it, then in the control source of the Wage Field you
can write
=[cboTask].Column(1)

And there is no need for code to be written
Assuming that the wage is the second column in the rowsource of the combo.
The count of the column start from 0.


--
I hope that helped
Good luck


Itman79 said:
I can't figure out how to populate a text box based on the selection of a
combo box in Access.

I have a form called "Evaluations" a combo box on that form lists the
available tasks. What I would like to do is populate a text box at the
bottom of the form labeled "Wage" with the corresponding wage to that task
and I can't figure out how to.

Anyhelp is greatly appreciated.

With Respect,

Christopher Gagnon
 
Both our suggestions can assist him. I gave him some ideas how this works
hoping that he will learn.

--
Maha Aruppthan Pappan
Nacap Asia Pacific (Thailand) Co., Ltd.


Ofer said:
If the Wage field is not bounded to the table, and you just use it to display
the wage without storing it, then in the control source of the Wage Field you
can write
=[cboTask].Column(1)

And there is no need for code to be written
Assuming that the wage is the second column in the rowsource of the combo.
The count of the column start from 0.


--
I hope that helped
Good luck


Itman79 said:
I can't figure out how to populate a text box based on the selection of a
combo box in Access.

I have a form called "Evaluations" a combo box on that form lists the
available tasks. What I would like to do is populate a text box at the
bottom of the form labeled "Wage" with the corresponding wage to that task
and I can't figure out how to.

Anyhelp is greatly appreciated.

With Respect,

Christopher Gagnon
 
Back
Top