I have a drop down combo box on a form, and when an item in the list is selected, the price for that item should show up in a label at the end of the row. Can anyone help me with the coding for this?
Instead of a label, you could use a text box with
enabled=no
tab-stop=no
locked=yes
so that it looks like a label. Then set the control source to be:
comboboxname!column(2)
This returns the value in the second column of the Row Source of that combo for the selected item.
I'm assuming here that the price is the second field in the Row Source for the combo box. For example, if you're selecting from Table1, then the Row Source will be either:
a Table1 (and the price is the second field)
b a select statement: e.g. Select field1, price from table1
If it is not then change column(2) to column(3) or whatever is suitable.
Following what SarahG posted if you want to use a label you can use the following in the combo after update event, to set the caption property of the label.
Again adjust the number in the Column to the appropriate column (note that the column numbers start at 0)
Private Sub cboName_AfterUpdate()
lblName.Caption = cboName.Column(1)
End Sub
There are two ways to write error-free programs; only the third one works.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.