Add All into a combo Box

StuckfromPR

Registered User.
Local time
Today, 16:55
Joined
Sep 15, 2008
Messages
18
I know this may be a stupid question, but I am trying to add the value all into a combo box. I have been able to insert all of the values of a query into it, but I want to give the option to users to select all of the values. Can someone help me with this. Thanks.
 
Use a multiselect list box?

Or you could use the additem method of the combobox to add the text string "all"
 
Do you literally mean select all of the items in a combo box or do you want a row in the combobox saying 'All'?

If you want to actually select all of the items in a combobox then you can't do that and would need to use a multiselect listbox like Chergh has said above.

If you just want to add a row saying 'All' then you can either use the method suggested by Chergh above or you could do change your query slightly to something like this...

Code:
SELECT FieldID, Field FROM tblFields UNION SELECT 0, "<All>" FROM tblFields ORDER BY Field

< comes before a when sorting so '<All>' will appear at the top of the combobox.

I hope that this helps :)
 
Yes I am trying to add the word 'All' into the values. I have done the query you suggested, this is how it looks,

SELECT DISTINCT ([table1].[field8]) AS Expr1 FROM table1 UNION SELECT 0, "<All>" FROM table1 ORDER BY [table1].[field8];

It gives me this error,
The number of columns in the two selected tables or queries of a union query do not match.

What should I do?
 
I was assuming that you had both a Unique Field and a value in your combo box.

So what you need is
Code:
[I]SELECT DISTINCT ([table1].[field8]) AS Expr1 FROM table1 UNION SELECT "<All>" FROM table1 ORDER BY [table1].[field8];[/I]

That should work :D
 
you cant now have the combobox bound to a field since <all> wont be an appropriate value

so your combobox afterupdate event will need to handle <all> as the selection
 

Users who are viewing this thread

Back
Top Bottom