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 bkrike 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

Status
Not open for further replies.

zp162002

Programmer
Feb 3, 2003
39
US
I would like to populate a text box using a value that was selected from a list box. Both the text box and list box are on the same form. Does anyone have any suggestions on how to code this? I'm assuming I have to loop through each item in the list box until I find the value that the user selected. Am I on the right track? Any help you can provide will be greatly appreciated.
 
In the AfterUpdate event procedure of the listbox, you may code something like this:
Me![textbox name] = Me![listbox name]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Assume the following:
your text box is named txt1
your list box is named lst1

txt1 = lst1.column(n,lst1.listindex)

This should insert the data in the nth column of the row selected by the user into txt1.

HTH.
 
What's the best way to loop through the list of items in the list box? I'm assuming I have to do this to pick the correct index number of the value chosen by the user.
 
The correct index number is .ListIndex
Feel free to play with the F1 and F2 key when you're in VBE.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top