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

Read All Values in Listbox Column 2

Status
Not open for further replies.

rookery

Programmer
Apr 4, 2002
384
GB
Is there anyway to access all the contents of a column in a Listbox without actually selecting anything in the Listbox?

For example something like the following:

For Each Row In Me.ListAdFields
MsgBox Me.ListAdFields.Column(2)
Next

Surely there has to be an easier way than to make a recordset out of the Listbox row-source query. Any ideas?
 
For i = 0 To Me("ListAdFields").ListCount - 1
MsgBox Me("ListAdFields").ItemData(i)
Next

Good luck
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Hi

Something like:

Dim i as Integer

For i = 0 To Me.ListAdFields.ListCount
MsgBox Me.ListAdFields.Column(i)
Next i

should do it

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Thanks guys for your responses. Dan, unfortunately the data I'm after isnt in the bound column which ItemData refers too.

Ken, I was getting an error with your solution so I tweaked it to get it to work - namely adding another argument to the Column method, to specify the Row. i.e.

For i = 0 To Me.ListAdFields.ListCount - 1
MsgBox Me.ListAdFields.Column(0,i)
Next i

Works a treat now! Cheers again.
 
what is easier than a query? why shy away from them. The query can be an unnamed one associated with the component only. easy, easy, easy

rollie@bwsys.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top