[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to deselect on a Microsoft Access listbox?

Posted on 2008-02-04
4
Medium Priority
?
991 Views
Last Modified: 2013-11-27
I'm having trouble deselecting a simple listbox with the following code:  Can someone help me with the proper syntax?  Here is the complete sub routine.  The code was taken from an earlier post:  http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_23040790.html  - None of the other suggestions has worked for me as well.

Private Sub cmdAll_Click()
  Dim i As Integer
  For i = 1 To 4
    Me.Controls("txtS" & i) = "*"
  Next
   'deselect all listbox
  With Me.lstDpts
    For i = 0 To .ListCount - 1
        .Selected(i) = False
    Next
  End With
  Me.Refresh
  DoEvents
  txtDpt = "*"
  Call cmdSeek_Click
End Sub
0
Comment
Question by:stephenlecomptejr
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
TextReport earned 2000 total points
ID: 20815722
Have you got this set to MultiSelect? Is not then just set the listbox to NULL.
Cheers, Andrew
0
 
LVL 28

Expert Comment

by:TextReport
ID: 20815773
Your code works fine for the deselection in Access 2000, what is the Call cmdSeek_Click doing?
Cheers, Andrew
Option Compare Database
Option Explicit
 
Private Sub cmdSelectAll_Click()
Dim i As Long
 
  With Me.lstEmployees
    For i = 0 To .ListCount - 1
        .Selected(i) = True
    Next
  End With
 
End Sub
 
Private Sub cmdSelectNone_Click()
Dim i As Long
 
  With Me.lstEmployees
    For i = 0 To .ListCount - 1
        .Selected(i) = False
    Next
  End With
 
End Sub

Open in new window

0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 20816655
Forgot to state Microsoft Access 2003 - sorry.

Multi-select set to None.
0
 
LVL 1

Author Closing Comment

by:stephenlecomptejr
ID: 31427816
Thanks for the fast reply!
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

611 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