By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,695 Members | 1,219 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,695 IT Pros & Developers. It's quick & easy.

Add "ALL" to combo box

P: 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
Share this Question
Share on Google+
5 Replies


missinglinq
Expert 2.5K+
P: 3,532
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
Expert 100+
P: 1,923
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

P: 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
Expert 100+
P: 1,923
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

P: 1
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

Post your reply

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