Ms access VBA remove selected item from listbox

databasedev.co.uk - database solutions and downloads for microsoft access

Microsoft Access Articles

  • General Microsoft Access Articles
  • Microsoft Access 2007 Articles
  • Tables
  • Queries
  • SQL
  • Forms
  • Reports
  • Macros
  • Modules & VBA
  • Data Models
  • Downloads

GUI Design

  • GUI Design Examples
  • Submit Your Examples

Resources

  • Resources
  • Database News
  • Knowledge Base
  • Microsoft Access Products, Tools & Add-In's

Online Shop

  • UK Visitors
  • US Visitors

Info

  • Contact Us
  • Advertise With Us
  • Link To Us
  • Write For Us
  • Competitions

Microsoft Access Listbox

How to Clear a Multi-Select Listbox

If you are using a Microsoft Access listbox on your form, you can set properties to allow the database user options as to how they make selections within the list box.

The MultiSelect property uses the following settings:

SettingVisual BasicDescription
None
0
(Default) Multiple selection isn't allowed.
Simple
1
Multiple items are selected or deselected by clicking them with the mouse or pressing the SPACEBAR.
Extended
2
Multiple items are selected by holding down SHIFT and clicking them with the mouse or by holding down SHIFT and pressing an arrow key to extend the selection from the previously selected item to the current item. You can also select items by dragging with the mouse. Holding down CTRL and clicking an item selects or deselects that item.

There may be occasions where you wish to clear the listbox selections, and if the list is large would like to complete this exercise automatically.

To add this functionality to a command button on your form you can use the following code (replace YourCommandButtonName and YourListBoxName with the names of your button and list box):

Private Sub YourCommandButtonName_Click() Dim varItm As Variant With YourListBoxName For Each varItm In .ItemsSelected .Selected(varItm) = False Next varItm End With End Sub

Clicking the command button will now clear the listbox of any selected items.

  • Site Map
  • Privacy Policy
  • Terms & Conditions
Contact Webmaster © 2003 - 2015 databasedev.co.uk | Advertising