Solved

ListBox Select Item without Index

Posted on 2008-06-19
1
2,090 Views
Last Modified: 2008-06-19
Hi,

How can I multiple select items in a ListBox without knowing the Index?

Any workaround?

I'm using MS Access 2002.
' Can I do something like this:

List134.Selected("item 1") = True

List134.Selected("item 2") = True
 

' Instead of this:

List134.Selected(0) = True

List134.Selected(1) = True

Open in new window

0
Comment
Question by:cukcuk
1 Comment
 
LVL 7

Accepted Solution

by:
Chrisedebo earned 50 total points
ID: 21820454
use a for next loop to loop through the items in the list and set selected to true if you find the value you are looking for.
Dim i as integer
 

For i = 0 To List134.ListCount - 1

    If List134.ItemData(i) = "item 1" Or List134.ItemData(i) = "item 2" Then List134.Selected(i) = True

Next

Open in new window

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now