Wednesday, May 16, 2012

Adding "All" to combobox

Table/Query
If the Row Source Type property is Table/Query then create a union query. If the first field in the is a primary key you can't use Null as the value of the field. Use a numeric value (-1 or 0 as an example)

With primary id field
SELECT DISTINCT [CategoryID], [Description] FROM [Categories] UNION SELECT Null as AllID, "(All)" AS AllField FROM [Categories] ORDER BY [Description]

Without primary id field
SELECT DISTINCT [CategoryID], [Description] FROM [Categories] UNION SELECT -1 as AllID, "(All)" AS AllField FROM [Categories] ORDER BY [Description]

Take note of the where the ORDER BY clause has been moved.

Value List
 If the Row Source Type property is Value List then just add (All) to the list.

Example
"(All)";"Hello"; "World"





   
   

No comments:

Post a Comment