Results 1 to 2 of 2
  1. #1
    BobbyN is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    1

    Question How to have a "All" or "No selection means all" option on my Listbox Filter?

    I'm learning VBA on my own sort of as I go along, and I've been doing an okay job but I'm stuck on one thing. So far I have created a form with a list box that acts as a filter to a query. If you click in "cities" Yonkers, Woodside and Jamaica and then the filter button - only properties with those cities come up.

    I want an "All" button or a condition that states that if none are selected, select all but I cant figure it out or find anything that works for me.

    Here is my code right now:
    Code:
    DoCmd.RunSQL ("Delete * from cities")


    For x = o To Me.CityList.ListCount - 1
    If Me.CityList.Selected(x) = True Then
    DoCmd.RunSQL ("Insert into cities values('" & _
    Me.CityList.ItemData(x) & "')")
    End If

    Next

    There is no way Im doing it the simplest, but it's working for me with this exception (I learned it from a video).

    Cities is a Table seperate from my properties table (which has all information) - from what I can tell, based on the filter it lists only those selected.
    CityList is the list box, pulling options from "All Cities" A query of every City through a group by function.

    Many Thanks! If you need any clarification let me know and Ill try my best to respond helpfully!

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    Cross posted here

    https://www.access-programmers.co.uk...d.php?t=292335

    @Bobby - please take a look at this thread http://www.excelguru.ca/content.php?184

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 07-07-2016, 12:22 PM
  2. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  3. Replies: 4
    Last Post: 01-22-2015, 10:30 AM
  4. Replies: 1
    Last Post: 09-03-2014, 03:27 AM
  5. Replies: 16
    Last Post: 11-01-2011, 01:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums