473,288 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

Combobox - option ALL

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
4 2627
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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Guillem | last post by:
Hola amigos, necesito realizar un script o algo similar para enlazar dos combobox. Están insertados en html uno detrás del otro y necesito que cuando se seleccione una posición del primero,...
6
by: Georges Heinesch | last post by:
An easy ComboBox question. ;) I would like to create a ComboBox, which permits to cycle through 3 subforms. These 3 subforms are entered in the ComboBox as Value List. The subforms should only...
2
by: Prabhat | last post by:
Hi all, I have one combobox where I want to display Name of the Products that are loaded in the collection object. But I am able to send only ID and Name of the Product where ID is the value of...
6
by: shailen21 | last post by:
Hi everybody, Im trying to use that piece of javascripts for 2 combo box in my web site but its nt working on Firefox but it works well in IE 6.0 :S Can someone please help me in solving this...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.