Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List box selection to textbox 1

Status
Not open for further replies.

uncchcs

Programmer
Jun 4, 2002
13
US
I have a list box with the following columns:
| Product | ProductID | Category |
On the same form, I have a textbox for each column in the listbox.
I want the user to be able to select a row from the listbox and automatically update(fill-in) the textboxes for each control.
 
Your goal can be accomplished as follows given the following assumptions:

1) List Box named "lstProduct" with a RowSource similar to "SELECT Product, ProductID, Category from tblProduct" assuming the name of the underlying table is "tblProduct"
2) Text Boxes named "txtProduct", "txtProductID" and "txtCategory"


This solution does not get into the issue of whether or not your form fields are bound to an underlying record source, however, this solution applies under any condition.

In the AfterUpdate event of the form's lstProduct control, the VB code would read as follows:

Private Sub lstProduct_AfterUpdate()

Me.txtProduct = Me.lstProduct.Column(0)
Me.txtProductID = Me.lstProduct.Column(1)
Me.txtCategory = Me.lstProduct.Column(2)

End Sub


Hope this points you in the right direction.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top