473,326 Members | 2,732 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,326 software developers and data experts.

Add "ALL" to combo box

2
How do I add "ALL" (as the top choicce) in a drop down combo box in Access? (combo box only has one field)
Jan 17 '08 #1
5 25025
missinglinq
3,532 Expert 2GB
Replace your combobox RowSource with this

Expand|Select|Wrap|Line Numbers
  1. SELECT YourField FROM YourTable
  2. UNION SELECT "<All>" FROM YourTable; 
filling in your actual field and table names.

Then use this code in the AfterUpdate of your combobox, once again filling in the actual name of your combobox:
Expand|Select|Wrap|Line Numbers
  1. Private Sub YourCombobox_AfterUpdate()
  2.   If Me.YourCombobox = "<All>" Then 
  3.     'Place code here to address selction of <All> 
  4.   End If
  5. End Sub
Welcome to TheScripts!

Linq ;0)>
Jan 17 '08 #2
puppydogbuddy
1,923 Expert 1GB
How do I add "ALL" (as the top choicce) in a drop down combo box in Access? (combo box only has one field)
To add All in the droplist of an unbound combobox, replace the RowSource property of the combobox with the following SQL string, replacing "yourComboColumn with the actual column name in your application.:
Expand|Select|Wrap|Line Numbers
  1. SELECT YourComboColumn As Filter, YourComboColumn FROM YourTable
  2. UNION SELECT "*" As Filter ," All" As YourComboColumn FROM YourTable
  3. ORDER BY YourComboColumn;
  4.  
The union query will generate 2 columns, the first is to be used as the bound (hidden) column, and the second will be used as the displayed column.so be sure and set these properties for your combobox:
Columns = 2
Bound Column = 1
Column Widths - 0; 2

Note the space before the letter A in " All".....this is designed so that All will sort as the top choice.in the collation sequence.

Expand|Select|Wrap|Line Numbers
  1. ---Example-------------
  2. SELECT City AS Filter, City FROM tbl_Customers
  3. UNION SELECT '*' AS Filter, "All" AS City FROM tbl_Customers
As a final step, you can set the default value property for the combobox to: * and it will default the combo selection to all if nothing is selected.
Jan 17 '08 #3
tombev
2
Maybe I should mention couple other things--- 1) My combo box is named: cboLEC2; 2) The bound column is: 1; 3) It uses a TAG function; 4) This is the RowSource I currently have: SELECT StatusSheetInfo.LEC FROM StatusSheetInfo GROUP BY StatusSheetInfo.LEC ORDER BY StatusSheetInfo.LEC;
Jan 18 '08 #4
puppydogbuddy
1,923 Expert 1GB
Maybe I should mention couple other things--- 1) My combo box is named: cboLEC2; 2) The bound column is: 1; 3) It uses a TAG function; 4) This is the RowSource I currently have: SELECT StatusSheetInfo.LEC FROM StatusSheetInfo GROUP BY StatusSheetInfo.LEC ORDER BY StatusSheetInfo.LEC;

Here is the way the row source should look if you followed the instructions that I provided you above:
Expand|Select|Wrap|Line Numbers
  1. SELECT LEC As Filter, LEC FROM StatusSheetInfo 
  2. UNION SELECT "*" As Filter ," All" As LEC FROM StatusSheetInfo
  3. GROUP BY StatusSheetInfo.LEC ORDER BY StatusSheetInfo.LEC;
Follow the rest of the instructions above and it should work.
Jan 18 '08 #5
well this is working i would like to know how to filter the data based on the four combobox and rowsource too
Nov 17 '10 #6

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

Similar topics

2
by: Dale Ring | last post by:
Access 2000 I am trying to add "ALL" to a combo that is used to filter a query. When "ALL" is selected no records show instead of ALL records showing. I have setup a "dummy" table (tblDum)...
1
by: Loreen | last post by:
I have been going through user groups and forums for the past 3 hours trying to figure out how to add "all" to my combo boxes. I've got two unbound comboboxes. Once only has one field...
3
by: tobhamlet | last post by:
If one is using a query as a Row Source on a Form, is there a way to set up a blank space, or to insert the word "ALL" in a combo box that represents ALL combo box row items. The scenario is as...
0
by: Greg Strong | last post by:
Hello All, In the past I've used a combo box with the 'row source' being an Access SQL union query to select "All" or 1 for only 1 criteria in a query. An example is as follows: SELECT 0 As...
4
by: meganrobertson22 | last post by:
Hi Everyone- I have a question about how to add and then use the "All" selection in a combo box. I am trying to figure out how to: (1) add "All" as a selection to a combo box and then (2)...
6
by: Mark | last post by:
I first read about this in mvps.org, but the code he gives doesn't seem to work for my form. I"ll post my code below. I'd love it if someone could point out the error in my code. BTW, this is my...
3
by: Jimmy | last post by:
I use a combo box to filter the results of a form. Sql for combo box is... SELECT StatusPriority, Status FROM tblStatus UNION Select = 0 as AllChoice, "Show All" as Bogus From tblStatus ORDER...
3
Zwoker
by: Zwoker | last post by:
Hi Everyone, I have a query that uses criteria from combo boxes in the form that runs it. When I had only discrete values in the combo boxes that matched the data that was being queried, the...
1
by: StuartD | last post by:
I have a sub form that is populated based on the selection of a year from a combo box on the main form. I'm trying to add a second main form combo box for item category to further filter the sub...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.