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

SELECT "ALL" COMMAND BUTTON

Status
Not open for further replies.

Angelique

Technical User
Mar 9, 2001
127
AU
Found some interesting code through the forum to load a listbox of reports. It's multi-select and works fine but I would like to know how I can code command buttons that will:

(a) Select "All" reports.
(b) De-select the recently selected ones.

Here's a challenge to those guys & gals who have nothing better to do on a Saturday night (EST).

Angelique
 
Not sure what you are wanting. Do you want to select all reports in your database? Or do you want to select all records in a particular report?

I am going to assume that that you want all records in a report. If so, you can add a list item to your called "All". May want to put it in parenthesis or quotes so that it is at the top of your list. In your query for the record source of your report, I will further assume that you are using a reference to your form's listbox. Replace with an IIF statement...

IIf(Forms![YourForm]![Listbox]="All",[YourField],Forms![YourForm]![Listbox])

Note the above is all one line. Hope this helps...

B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
Your assumption that I am wanting a list of reports and not all reports (I have another form for that using msysobject)that can be "all selected".

I will give the code a bash but how do I "deselect" as in the Access wizards?

All ideas are fully appreciated.

Angelique
 
In "regular" VB, a Listbox set to 2 (mult-select extended) responds to the Ctrl key, the shift-key and the right-click for selection and de-selection. The Ctrl key indicates that you do not want any already selected items to be deselected automatically. To select/deselect a single item, hold Ctrl and right-click the item. To select/deselect a range, hold down the Ctrl key and click the 1st item then hold the Ctrl and shift keys down while clicking the last in the range. You may do this in reverse order.You can select/deselect multiple single items or ranges using the Ctrl and Shift keys.
 
While I can tell the user to "double-click on the listbox to deselect, the user isn't "user friendly" and a command button to de-select is much easier on the user.

So having said that, how do I code "double-click" in code? or holding down the Ctrl key and right-click the item.

It's not like I am filtering as I can set it off & on.

Thanks in advance.


Angelique
 
Angelique
Add the following code to a command button named "cmdDeselectAll"

Code:
Private Sub cmdDeselectAll_Click()
    Dim intCurrentRow As Integer
    
    For intCurrentRow = 0 To lstSource.ListCount - 1
        Me!lstSource.Selected(intCurrentRow) = False
    Next intCurrentRow

End Sub

This will deselect any selected rows in a listbox call lstsource.

Read the "ListCount Property" topic in the on-line help for more info.

HTH

Lightning
 
Lightning,

Thanks! and I will lookup the "Listcount Property" as you suggested.


Angelique
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top