I have created a query the gives me a supplier number and the supplier name.
I want to use a combo box on a form to select the supplier number and be able to see the supplier name in a text field and store the information in a table.
You'll need to place a textbox on the form to hold the supplier's name, we'll call it txtSupplierName in this example, then use this code in your combobx, which is named Combobox26 in your posted db. You really need to give your control meaningful names instead of settling for theAccess assigned names:
Code:
Private Sub Combo26_AfterUpdate()
Me.txtSupplierName = Me.Combo26.Column(1)
End Sub
You'll also need to set the Control Source of the textbox to a field in your underlying table/query.
To the right of this box a small square will appear with an ellipsis [...]
Click on the ellipsis
A dialog box will come up with the options “Expression Builder” “Macro Builder” and “Code Builder”
Click on “Code Builder”
You will be taken into the code window, also called the code module or code editor, and will see something like this
Code:
Private Sub Combo26_AfterUpdate()
End Sub
Now you need to enter the line of code you were given
Me.txtSupplierName = Me.Combo26.Column(1)
into this empty sub, so that you end up with
Code:
Private Sub Combo26_AfterUpdate()
Me.txtSupplierName = Me.Combo26.Column(1)
End Sub
You’re now done. Either goto “View” on the menu and click on “Object” or look for the icon with the Access “Key” and click on it. This will take you back to the form’s Design View.
Here's Bob Larson's site that has some great graphics demonstrating the same thing:
I have created a query the gives me a supplier number and the supplier name.
I want to use a combo box on a form to select the supplier number and be able to see the supplier name in a text field and store the information in a table.