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

Combobox - option ALL

P: n/a
Is it possible to add an option ALL in the ist of a combobox that get its
values from a table?

Example:

in the combobox are the items from the table "days": monday, th....
The chosen value from the combobox is used in a query to select only the
records of the chosen day.
Now I want to have the possibility to have also ALL in my combobox-list to
select the records for all the days.

txs
Piet
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
piet wrote:
Is it possible to add an option ALL in the ist of a combobox that get its
values from a table?

Example:

in the combobox are the items from the table "days": monday, th....
The chosen value from the combobox is used in a query to select only the
records of the chosen day.
Now I want to have the possibility to have also ALL in my combobox-list to
select the records for all the days.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Perhaps a criteria like this (assumes the ComboBox has 2 columns: the
first column [bound column] is the days' week numbers; the second column
is the name of the week day - ALL has a NULL week day number):

PARAMETERS Forms!FormName!cboWeekDays Date;
SELECT ... etc.
WHERE Forms!FormName!cboWeekDays IS NULL OR
(Forms!FormName!cboWeekDays IS NOT NULL
AND WeekDay(DateColumn) = Forms!FormName!cboWeekDays)

[Change the names to suit your set up]

If ALL is selected, in the ComboBox Forms!FormName!cboWeekDays, IS NULL
evaluates to TRUE and all records are retrieved. If ALL is not selected
the OR (...) part of the criteria evaluates to true & selects only
records that have the date column w/ the required weekday value.

I got the above criteria idea from a db of samples queries from MS:

http://support.microsoft.com/default...b;en-us;182568
- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQG6PBoechKqOuFEgEQJG9gCfUsyTIa1AABnsjvUbZU3isS wDq+EAnRI2
1pM+Db1j/miKtZEMaWsPt3vw
=222i
-----END PGP SIGNATURE-----

Nov 12 '05 #2

P: n/a
piet wrote:
Is it possible to add an option ALL in the ist of a combobox that get its
values from a table?

Example:

in the combobox are the items from the table "days": monday, th....
The chosen value from the combobox is used in a query to select only the
records of the chosen day.
Now I want to have the possibility to have also ALL in my combobox-list to
select the records for all the days.

txs
Piet

I would use MG's solution for the query. If you want a word like ALL
into the combo I do something like this.

Assume I have an employee table; EmpID (Numberic, hidden in combo) and
EmpName (text and displayed in combo).

Select EmpID, EmpName From Employees
UNION
Select 0, "(All)" As EmpName From Employees
Order by EmpName

The select line after the union creates a dummy record.

I usually put () around the word All since a "(" is less than numbers
and characters and it will float to the top of the list. This is handy
if you have a field like EmpName where the word Albert would be less
than All in a sort order. I guess you could use a space if front of the
word All too.


Nov 12 '05 #3

P: n/a
"Salad" <oi*@vinegar.com> wrote in message
news:9y******************@newsread1.news.pas.earth link.net...
piet wrote:
Is it possible to add an option ALL in the ist of a combobox that get its values from a table?

Example:

in the combobox are the items from the table "days": monday, th....
The chosen value from the combobox is used in a query to select only the
records of the chosen day.
Now I want to have the possibility to have also ALL in my combobox-list to select the records for all the days.

txs
Piet

I would use MG's solution for the query. If you want a word like ALL
into the combo I do something like this.

Assume I have an employee table; EmpID (Numberic, hidden in combo) and
EmpName (text and displayed in combo).

Select EmpID, EmpName From Employees
UNION
Select 0, "(All)" As EmpName From Employees
Order by EmpName


I usually create a dummy table with a single row for these queries, that way
I can use union all and avoid the performance penalty of union. Also, you
can use a second sort column to make sure (All) is positioned at the top,
even if there are other records which would normally sort before "(All)",
such as those with leading spaces.

The query becomes:

select EmpID, EmpName, 1 as sort from Employees
union all
select 0, "(All)", 0 from dummy
order by sort, EmpName
You can create a dummy table that will only allow a single row like so:

Sub createDummy()
Dim sql As String
sql = "create table dummy(id int not null primary key, constraint
CK_dummy_id check(id=0))"
CurrentProject.Connection.Execute sql
End Sub






Nov 12 '05 #4

P: n/a
OM
There's an answer to this in the FAQ's for this group, I've seen it.Go to

http://www.mvps.org/access/netiquette.htm

and have a look.

OM
"MGFoster" <me@privacy.com> wrote in message
news:ja******************@newsread1.news.pas.earth link.net...
piet wrote:
Is it possible to add an option ALL in the ist of a combobox that get its values from a table?

Example:

in the combobox are the items from the table "days": monday, th....
The chosen value from the combobox is used in a query to select only the
records of the chosen day.
Now I want to have the possibility to have also ALL in my combobox-list to select the records for all the days.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Perhaps a criteria like this (assumes the ComboBox has 2 columns: the
first column [bound column] is the days' week numbers; the second column
is the name of the week day - ALL has a NULL week day number):

PARAMETERS Forms!FormName!cboWeekDays Date;
SELECT ... etc.
WHERE Forms!FormName!cboWeekDays IS NULL OR
(Forms!FormName!cboWeekDays IS NOT NULL
AND WeekDay(DateColumn) = Forms!FormName!cboWeekDays)

[Change the names to suit your set up]

If ALL is selected, in the ComboBox Forms!FormName!cboWeekDays, IS NULL
evaluates to TRUE and all records are retrieved. If ALL is not selected
the OR (...) part of the criteria evaluates to true & selects only
records that have the date column w/ the required weekday value.

I got the above criteria idea from a db of samples queries from MS:

http://support.microsoft.com/default...b;en-us;182568
- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQG6PBoechKqOuFEgEQJG9gCfUsyTIa1AABnsjvUbZU3isS wDq+EAnRI2
1pM+Db1j/miKtZEMaWsPt3vw
=222i
-----END PGP SIGNATURE-----

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.