Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Invert List Box Selection

Posted on 2013-05-23
1
Medium Priority
?
585 Views
Last Modified: 2013-05-23
Hi,

I have a MS Access form with a multiselect list box.

I want to programatically invert the selection, ie, iterate through all the entries in the listbox and turn off the ones that are selected and turn on the ones that are not selected.

How can I achieve this please?
0
Comment
Question by:rowansmith
1 Comment
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 39190235
Try looping through the listbox, toggling the Selected property of each item:

    Dim i As Integer
    
    For i = 0 To (Me.YourListBox.ListCount - 1)
        Me.YourListBox.Selected(i) = Not Me.YourListBox.Selected(i)
    Next i

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

963 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