MS Access VBA – How To Add A ‘Select All’ Option To A Combo Box

Normally with a combo box, you can select only 1 item
in the drop down list. But what happens when you want to “Select All”
the items in the list?

I have done this 2 different ways, 1 way is to put a checkbox on the form,
called “All”, and then have the combo box list, and the other way is giving
the user the option to “Select All” in the same list.

This eliminates the need for extra coding and for an extra check box control, thus
it SAVES TIME.

In this video, you will find out how to add the ability to “Select All”
to a combo box.

The “(All)” is done with a UNION query.

Here is the sql:

SELECT SupplierID, CompanyName FROM tblSuppliers UNION Select 0 as AllChoice , “(All)” as Bogus From tblSuppliers

This goes into the “Rowsource” of the dropdown list.

—————
Here is another sample (now with a sort):

SELECT “(ALL)” AS Period FROM YTDFlowmonth UNION SELECT DISTINCT Period FROM YTDFlowmonth ORDER BY Period

—————

Now (All) is part of the select list.

Select it and click “Show Supplier”, and you’ll see that it
becomes united with the list, and shows in the message box as
a valid item.

The following video shows you how to do it:

Hope it helps, here is the database:

add_select_all_to_combobox.mdb

Click here for more information on comboboxes and filter related posts.




By the way, if you got or are getting value from the VBA information, please give me a tip, thanks!


These posts may help answer your question too...

How To Escape Apostrophe In SQL Update Query

If you are looping a table with thousands of records, you’ll probably run into at least one that has an apostrophe in the field name. Like “Mike’s” or “M’cormick”, or something else. Anyway, here is one way to escape the string when you are doing your update query. Option Compare Database Sub YDriveLoop() ‘4/23/24 erik@loeblcomservices.com […]

How To Parse A Flat File In Excel VBA

In another post I demonstrated how to access a file on your computer using the MS Office Library. Here it is if you don’t know what I’m talking about. In this post, I am going to show you how to access the file and load it into your spreadsheet. I will do the same thing […]

How can I interact with other Office applications (Excel) using VBA in Access?

Need to write your Access data or query to an Excel file? Here is the how to do it: Most people are familiar with Excel and know how to use it well (enough), and when you start talking about Access, they get scared off, and don’t know what to do anymore. Well, here you are […]

How To Create A Parameter Query In Access

A parameter query changes your ordinary static access query to be more dynamic and interactive. It will ask you a question about what you want to search for, allowing you to do a search query multiple times instead of just once. You can do your parameter query straight from the QBE (Query By Example) Editor, […]

Previous Post

Resolution – VBA Error 49 – Bad DLL Calling Convention

Next Post

How to create SQL Statement from Combobox Selections