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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List box 1

Status
Not open for further replies.

dbero

Technical User
Mar 31, 2005
109
US
Is it possible using VBA to identify the values of a focus record in a list box. Or put another way, assign variables the values from a selected record in a listbox? What I am attempting to do is delete a single record from the listbox.

thank you,
 
Have a look at the ListIndex property of the ListBox object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I don't see a listindex property. Where would I go to view this? thanks
 
In the immediate window (Ctrl+G) type listindex and press the F1 key.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Perhaps I wasn't clear. I don't want to view the values, i want to read in each field, and assign that value to a unique variable. those variables will then become a query to identify that particular record. Is this clearer?

 
So you have a list box:

Item1
Item2
Item3

The user selects Item1, you want to be able to assign 'Item1' to a variable?

Is it a multiselect list box?


Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins
 
Thank you. It is not a multiselect. There are 4 fieds in each record. The source for the listbox is from a joined query. When a record in the listbox is highlighted, I want to assign each of the 4 values to 4 different variables.

Thank you
 
OK, you wanted to play with the Column property of your listbox.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Exactly. I want to know each value in each column for the selected row!
 
So, again, press the F1 key when the cursor is inside the Column word.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Code:
Variable1 = ListBox.Columns(0)
Variable2 = ListBox.Columns(1)
Variable3 = ListBox.Columns(2)
...etc...

Ed Metcalfe.

Please do not feed the trolls.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top