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.:
-
SELECT YourComboColumn As Filter, YourComboColumn FROM YourTable
-
UNION SELECT "*" As Filter ," All" As YourComboColumn FROM YourTable
-
ORDER BY YourComboColumn;
-
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.
-
---Example-------------
-
SELECT City AS Filter, City FROM tbl_Customers
-
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.