473,408 Members | 2,813 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,408 software developers and data experts.

Adding <All> as options in 2 combo boxes

I am working on a report filter form. It has 2 combo boxes
(cmboSelectSubject and cmboSelectCategory) to select criteria.
Selecting an entry in combo 1
restricts the options available in combo 2.

The row source for combo2 is:

SELECT DISTINCT tblComplaintCategory.fldComplaintCategory,
tblComplaintCategory.fldComplaintCategoryID,
tblComplaintSubjects.fldComplaintSubjectID
FROM (tblComplaints INNER JOIN tblComplaintCategory ON
tblComplaints.fldComplaintCategory =
tblComplaintCategory.fldComplaintCategoryID) INNER JOIN
tblComplaintSubjects ON tblComplaints.fldComplaintSubject =
tblComplaintSubjects.fldComplaintSubjectID
WHERE
(((tblComplaintSubjects.fldComplaintSubjectID)=[Forms]![frmReports]![cmboSelectSubject]))
ORDER BY tblComplaintCategory.fldComplaintCategory;
Pressing OK opens the report and the SQL for the report is constructed
on the fly. This is straightforward enough, but I want to add an
option "All" in

both combo boxes. I understand how to build the code to get the "All"
option in one combo box:-

SELECT 0 as fldComplaintsubjectID, "[All]" as fldComplaintsubject from
tblComplaintsubjects UNION select
tblComplaintsubjects.fldComplaintsubjectID,
tblComplaintsubjects.fldComplaintsubject from tblComplaintsubjects
ORDER BY fldComplaintsubject;
- but the <row sourcecode for combo 2 won't work to restrict the
options in combo 2 when using the code for the "All" option in combo1.
How do I overcome this?

Secondly, I want to add an "All" option to combo2. How do I make this
work with the restriction aspect of combo1?

Finally, once I get the 2 "All" options working, how do I test for
their presence when the user selects tham both as options and presses
OK for the report?

Thanks for any help you can give.
Gordon

Dec 6 '06 #1
5 2194
On 6 Dec 2006 02:23:38 -0800, co********@hotmail.co.uk wrote:

Read this article:
http://www.mvps.org/access/forms/frm0043.htm
And bookmark that site!

-Tom.

>I am working on a report filter form. It has 2 combo boxes
(cmboSelectSubject and cmboSelectCategory) to select criteria.
Selecting an entry in combo 1
restricts the options available in combo 2.

The row source for combo2 is:

SELECT DISTINCT tblComplaintCategory.fldComplaintCategory,
tblComplaintCategory.fldComplaintCategoryID,
tblComplaintSubjects.fldComplaintSubjectID
FROM (tblComplaints INNER JOIN tblComplaintCategory ON
tblComplaints.fldComplaintCategory =
tblComplaintCategory.fldComplaintCategoryID) INNER JOIN
tblComplaintSubjects ON tblComplaints.fldComplaintSubject =
tblComplaintSubjects.fldComplaintSubjectID
WHERE
(((tblComplaintSubjects.fldComplaintSubjectID)=[Forms]![frmReports]![cmboSelectSubject]))
ORDER BY tblComplaintCategory.fldComplaintCategory;
Pressing OK opens the report and the SQL for the report is constructed
on the fly. This is straightforward enough, but I want to add an
option "All" in

both combo boxes. I understand how to build the code to get the "All"
option in one combo box:-

SELECT 0 as fldComplaintsubjectID, "[All]" as fldComplaintsubject from
tblComplaintsubjects UNION select
tblComplaintsubjects.fldComplaintsubjectID,
tblComplaintsubjects.fldComplaintsubject from tblComplaintsubjects
ORDER BY fldComplaintsubject;
- but the <row sourcecode for combo 2 won't work to restrict the
options in combo 2 when using the code for the "All" option in combo1.
How do I overcome this?

Secondly, I want to add an "All" option to combo2. How do I make this
work with the restriction aspect of combo1?

Finally, once I get the 2 "All" options working, how do I test for
their presence when the user selects tham both as options and presses
OK for the report?

Thanks for any help you can give.
Gordon
Dec 6 '06 #2
Tom,
Thanks for responding but your reply does not help me. If you read my
original post again, you will see that the second bit of code I quoted
uses the same kind of code (union query) that you referred me to. My
question is more complicated than how simply to add an "All" option to
a combo box.

Gordon

Tom van Stiphout wrote:
On 6 Dec 2006 02:23:38 -0800, co********@hotmail.co.uk wrote:

Read this article:
http://www.mvps.org/access/forms/frm0043.htm
And bookmark that site!

-Tom.

I am working on a report filter form. It has 2 combo boxes
(cmboSelectSubject and cmboSelectCategory) to select criteria.
Selecting an entry in combo 1
restricts the options available in combo 2.

The row source for combo2 is:

SELECT DISTINCT tblComplaintCategory.fldComplaintCategory,
tblComplaintCategory.fldComplaintCategoryID,
tblComplaintSubjects.fldComplaintSubjectID
FROM (tblComplaints INNER JOIN tblComplaintCategory ON
tblComplaints.fldComplaintCategory =
tblComplaintCategory.fldComplaintCategoryID) INNER JOIN
tblComplaintSubjects ON tblComplaints.fldComplaintSubject =
tblComplaintSubjects.fldComplaintSubjectID
WHERE
(((tblComplaintSubjects.fldComplaintSubjectID)=[Forms]![frmReports]![cmboSelectSubject]))
ORDER BY tblComplaintCategory.fldComplaintCategory;
Pressing OK opens the report and the SQL for the report is constructed
on the fly. This is straightforward enough, but I want to add an
option "All" in

both combo boxes. I understand how to build the code to get the "All"
option in one combo box:-

SELECT 0 as fldComplaintsubjectID, "[All]" as fldComplaintsubject from
tblComplaintsubjects UNION select
tblComplaintsubjects.fldComplaintsubjectID,
tblComplaintsubjects.fldComplaintsubject from tblComplaintsubjects
ORDER BY fldComplaintsubject;
- but the <row sourcecode for combo 2 won't work to restrict the
options in combo 2 when using the code for the "All" option in combo1.
How do I overcome this?

Secondly, I want to add an "All" option to combo2. How do I make this
work with the restriction aspect of combo1?

Finally, once I get the 2 "All" options working, how do I test for
their presence when the user selects tham both as options and presses
OK for the report?

Thanks for any help you can give.
Gordon
Dec 6 '06 #3
Tom,
Thanks for responding but your reply does not help me. If you read my
original post again, you will see that the second bit of code I quoted
uses the same kind of code (union query) that you referred me to. My
question is more complicated than how simply to add an "All" option to
a combo box.

Gordon

Tom van Stiphout wrote:
On 6 Dec 2006 02:23:38 -0800, co********@hotmail.co.uk wrote:

Read this article:
http://www.mvps.org/access/forms/frm0043.htm
And bookmark that site!

-Tom.

I am working on a report filter form. It has 2 combo boxes
(cmboSelectSubject and cmboSelectCategory) to select criteria.
Selecting an entry in combo 1
restricts the options available in combo 2.

The row source for combo2 is:

SELECT DISTINCT tblComplaintCategory.fldComplaintCategory,
tblComplaintCategory.fldComplaintCategoryID,
tblComplaintSubjects.fldComplaintSubjectID
FROM (tblComplaints INNER JOIN tblComplaintCategory ON
tblComplaints.fldComplaintCategory =
tblComplaintCategory.fldComplaintCategoryID) INNER JOIN
tblComplaintSubjects ON tblComplaints.fldComplaintSubject =
tblComplaintSubjects.fldComplaintSubjectID
WHERE
(((tblComplaintSubjects.fldComplaintSubjectID)=[Forms]![frmReports]![cmboSelectSubject]))
ORDER BY tblComplaintCategory.fldComplaintCategory;
Pressing OK opens the report and the SQL for the report is constructed
on the fly. This is straightforward enough, but I want to add an
option "All" in

both combo boxes. I understand how to build the code to get the "All"
option in one combo box:-

SELECT 0 as fldComplaintsubjectID, "[All]" as fldComplaintsubject from
tblComplaintsubjects UNION select
tblComplaintsubjects.fldComplaintsubjectID,
tblComplaintsubjects.fldComplaintsubject from tblComplaintsubjects
ORDER BY fldComplaintsubject;
- but the <row sourcecode for combo 2 won't work to restrict the
options in combo 2 when using the code for the "All" option in combo1.
How do I overcome this?

Secondly, I want to add an "All" option to combo2. How do I make this
work with the restriction aspect of combo1?

Finally, once I get the 2 "All" options working, how do I test for
their presence when the user selects tham both as options and presses
OK for the report?

Thanks for any help you can give.
Gordon
Dec 6 '06 #4
On 6 Dec 2006 02:23:38 -0800, co********@hotmail.co.uk wrote:
>I am working on a report filter form. It has 2 combo boxes
(cmboSelectSubject and cmboSelectCategory) to select criteria.
Selecting an entry in combo 1
restricts the options available in combo 2.

The row source for combo2 is:

SELECT DISTINCT tblComplaintCategory.fldComplaintCategory,
tblComplaintCategory.fldComplaintCategoryID,
tblComplaintSubjects.fldComplaintSubjectID
FROM (tblComplaints INNER JOIN tblComplaintCategory ON
tblComplaints.fldComplaintCategory =
tblComplaintCategory.fldComplaintCategoryID) INNER JOIN
tblComplaintSubjects ON tblComplaints.fldComplaintSubject =
tblComplaintSubjects.fldComplaintSubjectID
WHERE
(((tblComplaintSubjects.fldComplaintSubjectID)=[Forms]![frmReports]![cmboSelectSubject]))
ORDER BY tblComplaintCategory.fldComplaintCategory;
Pressing OK opens the report and the SQL for the report is constructed
on the fly. This is straightforward enough, but I want to add an
option "All" in

both combo boxes. I understand how to build the code to get the "All"
option in one combo box:-

SELECT 0 as fldComplaintsubjectID, "[All]" as fldComplaintsubject from
tblComplaintsubjects UNION select
tblComplaintsubjects.fldComplaintsubjectID,
tblComplaintsubjects.fldComplaintsubject from tblComplaintsubjects
ORDER BY fldComplaintsubject;
- but the <row sourcecode for combo 2 won't work to restrict the
options in combo 2 when using the code for the "All" option in combo1.
How do I overcome this?
Change the rowsource of combo 2 depending on the selection of combo 1 using the
AfterUpdate event of Combo1. ie. Remove the Where clause from the rowsource if
"All" is selected in combo 1.

Something like (syntax unchecked) -

Dim strSQL as String
If Me.Combo1=0 Then 'All selected
strSQL="SELECT 'All' As fldComplaintCategory, 0 AS fldComplaintSubjectID,
0 As fldComplaintSubjectID FROM tblComplaintCategory
UNION SELECT tblComplaintCategory.fldComplaintCategory,
tblComplaintCategory.fldComplaintCategoryID,
tblComplaintSubjects.fldComplaintSubjectID
FROM (tblComplaints INNER JOIN tblComplaintCategory ON
tblComplaints.fldComplaintCategory =
tblComplaintCategory.fldComplaintCategoryID) INNER JOIN
tblComplaintSubjects ON tblComplaints.fldComplaintSubject =
tblComplaintSubjects.fldComplaintSubjectID
ORDER BY tblComplaintCategory.fldComplaintCategory;"
Else
strSQL="SELECT 'All' As fldComplaintCategory, 0 AS fldComplaintSubjectID,
0 As fldComplaintSubjectID FROM tblComplaintCategory
UNION SELECT tblComplaintCategory.fldComplaintCategory,
tblComplaintCategory.fldComplaintCategoryID,
tblComplaintSubjects.fldComplaintSubjectID
FROM (tblComplaints INNER JOIN tblComplaintCategory ON
tblComplaints.fldComplaintCategory =
tblComplaintCategory.fldComplaintCategoryID) INNER JOIN
tblComplaintSubjects ON tblComplaints.fldComplaintSubject =
tblComplaintSubjects.fldComplaintSubjectID
WHERE

(((tblComplaintSubjects.fldComplaintSubjectID)=[Forms]![frmReports]![cmboSelectSubject]))
ORDER BY tblComplaintCategory.fldComplaintCategory;"
End If

Me.Combo2.RowSource=strSQL
>Secondly, I want to add an "All" option to combo2. How do I make this
work with the restriction aspect of combo1?
See above
>
Finally, once I get the 2 "All" options working, how do I test for
their presence when the user selects tham both as options and presses
OK for the report?
If Me.Combo1 = 0 AND Me.Combo2 = 0 Then
'open report to display all records
Else
'open report using to display filtered records.
End If

>
Thanks for any help you can give.
Gordon
Wayne Gillespie
Gosford NSW Australia
Dec 6 '06 #5
co********@hotmail.co.uk wrote:
I am working on a report filter form. It has 2 combo boxes
(cmboSelectSubject and cmboSelectCategory) to select criteria.
Selecting an entry in combo 1
restricts the options available in combo 2.

The row source for combo2 is:
Pressing OK opens the report and the SQL for the report is constructed
on the fly.
This is straightforward enough, but I want to add an
option "All" in
As you've noted you have a good understanding how to add the option in
the link Tom provided.
- but the <row sourcecode for combo 2 won't work to restrict the
options in combo 2 when using the code for the "All" option in combo1.
How do I overcome this?
Secondly, I want to add an "All" option to combo2. How do I make this
work with the restriction aspect of combo1?
I think what you're saying is that the where clause:

fldComplaintSubjectID=[Forms]![frmReports]![cmboSelectSubject]

doesn't work if the value of cmboSelectSubject is 0, from picking the
All option.

Personally, what I do is construct the SQL for the second combo box's
row source in the on got focus event of the second combo. You could
also do it in the afterupdate event of the first combo box. For example:

Sub cmboSelectCategory_GotFocus()

dim strS as string

on Error goto err_Proc

strS = "SELECT fldComplaintCategory, "
strS = strS & "fldComplaintCategoryID, "
strS = strS & "fldComplaintSubjectID "
strS = strS & "FROM (tblComplaints INNER JOIN tblComplaintCategory ON
tblComplaints.fldComplaintCategory =
tblComplaintCategory.fldComplaintCategoryID) "
strS = strS & "INNER JOIN
tblComplaintSubjects ON tblComplaints.fldComplaintSubject =
tblComplaintSubjects.fldComplaintSubjectID"

'Now, set up the where clause as per the choice in
'cmboSelectSubject:

If me.cmboSelectSubject <0 then 'if 0, don't use a where clause
strs = strS & "WHERE fldComplaintSubjectID = " & me.cmboSelectSubject
end if

'Add the dummy select clause for the union query

strS = strS & SELECT ""<All>"", "
strS = strS & "0, "
strS = strS & "0 "
strS = strS & "FROM tblComplaints"

strs = strs & "ORDER BY 1"

'Now give cmboSelectCategory the new rowsource
'Don't need to change it unless the SQL is different

if me.cmboSelectCategory.rowsource <strs then
me.cmboSelectCategory.rowsource =strS
'A requery might not be necessary as changing the rowsource
'My automatically requery.
me.cmboSelectCategory.requery
end if

Exit_Proc:

Exit Sub

Err_Proc:
Select case err.number
case else
msgbox "Error " & err.number & " " & err.description, _
vbexclamation, "cmboSelectCategory got focus", _
err.helpfile, err.helpcontext
resume exit_Proc
end select

End Sub
The same way you did the union query for

Finally, once I get the 2 "All" options working, how do I test for
their presence when the user selects tham both as options and presses
OK for the report?

You say the SQL is being constructed on the fly. In the report on open
or whatever even you're using just inspect cmboSelectSubject and
cmboSelectCategory, ie,

If Forms.frmName.cmboSelectSubject =6 then...
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Dec 6 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: nosferatu_1_1 | last post by:
Hi, I would like to create a schema that validate the following xml: <music> <pop/> <rock/> <pop/> </music>
0
by: Olly | last post by:
I am using the following pure css layout with a header and footer: http://www.fu2k.org/alex/css/layouts/3Col_NN4_FMFM.mhtml The left column floats to the left of the main content (middle...
4
by: Ferd Berfel | last post by:
given this code: <select name="mySelect" size="3" multiple> <option>one</option> <option>two</option> <option>three</option> <option>four</option> <option>five</option> <option...
4
by: joiv | last post by:
I'm making a <select></select> with lots of <option></option>. It contains all possible options. Because of the length of the list, I also have an <input type="text">. This is what I wish to do:...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
3
by: deko | last post by:
SELECT TxType_ID, TxTypeName FROM tblTxType UNION SELECT Top 1 TxType_ID, "<Payment Account>" FROM tblTxType ORDER BY ; The problem I'm having is that the Top 1 "TxType_ID" brings up a...
3
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt,...
7
Ranjan kumar Barik
by: Ranjan kumar Barik | last post by:
Hi! I want to create a combo box that will contain too many data like name of all the countries. Is there any other method I can use to do that without adding all of them using the <option>...
1
by: Axel Gallus | last post by:
I add some option items to a <selectbox by: ----- MySelect.length = null; // clears all options in select element for ( var i in Somename ) { MySelect.options = new Option(Somename,
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.