[dba-SQLServer]Clear Selections in a ListBox

Mike and Doris Manning mikedorism at ntelos.net
Mon Mar 24 13:22:43 CST 2003


If you want to save Server/Client resources, you could loop through the
listbox and set the SELECTED property of each item to False.  The example
below will work in Access 2000.

Dim lcv as Integer

If Me.Listbox.ItemsSelected.Count > 0 Then
   For lcv = 0 to Me.Listbox.ListCount - 1
      If Me.Listbox.Selected(lcv) = True then Me.Listbox.Selected(lcv) =
False
   Next lcv
End If

Note:  If you have header rows turned on, then you will need to start the
count at 1.

Doris Manning
Database Administrator
Hargrove Inc.
www.hargroveinc.com


-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan
Zeller
Sent: Monday, March 24, 2003 02:11 PM
To: dba-SQLServer at databaseadvisors.com
Subject: [dba-SQLServer]Clear Selections in a ListBox


In a multiselect listbox, what is the best way to clear selections user has
made.  The recordsource for the listbox is a stored procedure so what I have
been doing is on click of a clear list button, I reset the rowsource of the
listbox as in:  

Me.listbox.rowsource = "exec dbo.MySprocName '" & strMyParamter & "'"

Is this the best way?  Or, should I somehow be looping through the records
to see which items are selected and then unselect them?

--Susan


Susan B. Zeller
Office of Information Systems
College of Continuing Education
University of Minnesota
306 Wesbrook Hall
77 Pleasant Street SE
Minneapolis, MN 55455
Phone:  612-626-4785
Fax:  612-625-2568


_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com




More information about the dba-SQLServer mailing list