473,385 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

1
Hello everyone!

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:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL ("Delete * from cities")
  2. For x = o To Me.CityList.ListCount - 1
  3.     If Me.CityList.Selected(x) = True Then
  4.         DoCmd.RunSQL ("Insert into cities values('" & _
  5.             Me.CityList.ItemData(x) & "')")
  6.     End If
  7. 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!
Feb 28 '17 #1
1 751
PhilOfWalton
1,430 Expert 1GB
Sorry to say that looks messy, though I'm far from clear on what you are trying to achieve.

A good start would be to give an outline of your 2 tables and their relationship and exactly what information you are trying to obtain.

Phil
Mar 1 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: James Goodman | last post by:
I have a listbox named sub1 on an asp page. I need to fill this list with values from a table. These are selected based upon the selection of a value/s in another listbox. It was suggested that I...
2
by: c_kubie | last post by:
I am not very Access03 efficient. I have managed to create a listbox within a form. I would like to have the listbox selection update the form with the appropriate information from that row. ...
2
by: Alpha | last post by:
User selected multiple items in the listbox. How can I put these selected ids into a dataset table so I can pass it to my crystal report? Thanks, Alpha
2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
3
by: Chris Kettenbach | last post by:
Hello all, Quick question. I have a listbox that is populated by items from a database. When the user select something from the list, I want to populate another listbox based on the selection in...
6
by: ortaias | last post by:
I have a listbox which can display all records or provide a limited list based on a filter derived from an optiongroup. The code works except in the one situation where the listbox filter is...
2
samycbe
by: samycbe | last post by:
I am displaying i number of rows with 3 columns (1 sno 2 description 3 category) . the category is in listbox. and i am generating new row for the entry after display. S.No will be generated....
5
by: Hydrogen | last post by:
Hello there, I've got a few dropdown 'SELECT' controls on a page that represent the days months and years. A little popup calendar will send back the day month and year and insert them into a...
2
by: lhsiber | last post by:
I am new to access and am having a problem with filtering. Here is a little bit of my setup: I have a main form that has a listbox so that users can choose one or many groups in which to display...
0
by: emtang | last post by:
When right click on the form, how do I get the menu option of 'Filter By Selection' 'Filter Excluding Selection' 'Apply Filter/Sort', 'Remove Filter/Sort' and so on.... as seen in the second part...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.