Combo Box to open report

B

Bhupinder Rayat

Hi,

I have a report which opens a query, based on the priority number (1,2 or 3).

In the query criterira for Priority I have the following.

<[Show all CP with priority <=]

This brings up a prompt box when I open the report where I type 1, 2 or 3 to
bring up the records with that priority.

I want to change the caption to a combo box where I can select 1, 2, or 3
rather than typing it in, and also have the option to display ALL records.

Can anyone help please?

Thanks,

B/
 
D

Douglas J. Steele

You cannot make Access prompt you with a combo box. However, you can create
an unbound form with a combo box that has four values: 1, 2, 3 and All (if
you're getting the numbers from a table rather than hard-coding them, see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web" for how to
add "All" to your query)

Change your query's criteria to

< [Forms]![NameOfForm]![NameOfComboBox) OR
([Forms]![NameOfForm]![NameOfComboBox) = "All")

Make sure that the form is open when the query runs: Access will not open
the form for you either.
 
B

Bhupinder Rayat

Hi Douglas,

Thanks for this.

I have added All to the query but I'm still having trouble bringing up the
combo box.

Do you want me to use add the first line in criteria and the second line in
or?
so...

Criteria: < [Forms]![frmPriority]![Combo4]
or: ([Forms]![frmPriority]![Combo4] = "All")

Like this ?

B/


Douglas J. Steele said:
You cannot make Access prompt you with a combo box. However, you can create
an unbound form with a combo box that has four values: 1, 2, 3 and All (if
you're getting the numbers from a table rather than hard-coding them, see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web" for how to
add "All" to your query)

Change your query's criteria to

< [Forms]![NameOfForm]![NameOfComboBox) OR
([Forms]![NameOfForm]![NameOfComboBox) = "All")

Make sure that the form is open when the query runs: Access will not open
the form for you either.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
Hi,

I have a report which opens a query, based on the priority number (1,2 or
3).

In the query criterira for Priority I have the following.

<[Show all CP with priority <=]

This brings up a prompt box when I open the report where I type 1, 2 or 3
to
bring up the records with that priority.

I want to change the caption to a combo box where I can select 1, 2, or 3
rather than typing it in, and also have the option to display ALL records.

Can anyone help please?

Thanks,

B/
 
D

Douglas J. Steele

I was suggesting putting both statements in the same criteria cell.

It'll likely be easier if you switch to SQL view and put the criteria there.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
Hi Douglas,

Thanks for this.

I have added All to the query but I'm still having trouble bringing up the
combo box.

Do you want me to use add the first line in criteria and the second line
in
or?
so...

Criteria: < [Forms]![frmPriority]![Combo4]
or: ([Forms]![frmPriority]![Combo4] = "All")

Like this ?

B/


Douglas J. Steele said:
You cannot make Access prompt you with a combo box. However, you can
create
an unbound form with a combo box that has four values: 1, 2, 3 and All
(if
you're getting the numbers from a table rather than hard-coding them, see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web" for how
to
add "All" to your query)

Change your query's criteria to

< [Forms]![NameOfForm]![NameOfComboBox) OR
([Forms]![NameOfForm]![NameOfComboBox) = "All")

Make sure that the form is open when the query runs: Access will not open
the form for you either.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
Hi,

I have a report which opens a query, based on the priority number (1,2
or
3).

In the query criterira for Priority I have the following.

<[Show all CP with priority <=]

This brings up a prompt box when I open the report where I type 1, 2 or
3
to
bring up the records with that priority.

I want to change the caption to a combo box where I can select 1, 2, or
3
rather than typing it in, and also have the option to display ALL
records.

Can anyone help please?

Thanks,

B/
 
D

Douglas J. Steele

And just in case I've misinterpretted "still having trouble bringing up the
combo box", hopefully you noticed my comment to "Make sure that the form is
open when the query runs."

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
Hi Douglas,

Thanks for this.

I have added All to the query but I'm still having trouble bringing up the
combo box.

Do you want me to use add the first line in criteria and the second line
in
or?
so...

Criteria: < [Forms]![frmPriority]![Combo4]
or: ([Forms]![frmPriority]![Combo4] = "All")

Like this ?

B/


Douglas J. Steele said:
You cannot make Access prompt you with a combo box. However, you can
create
an unbound form with a combo box that has four values: 1, 2, 3 and All
(if
you're getting the numbers from a table rather than hard-coding them, see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web" for how
to
add "All" to your query)

Change your query's criteria to

< [Forms]![NameOfForm]![NameOfComboBox) OR
([Forms]![NameOfForm]![NameOfComboBox) = "All")

Make sure that the form is open when the query runs: Access will not open
the form for you either.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
Hi,

I have a report which opens a query, based on the priority number (1,2
or
3).

In the query criterira for Priority I have the following.

<[Show all CP with priority <=]

This brings up a prompt box when I open the report where I type 1, 2 or
3
to
bring up the records with that priority.

I want to change the caption to a combo box where I can select 1, 2, or
3
rather than typing it in, and also have the option to display ALL
records.

Can anyone help please?

Thanks,

B/
 
B

Bhupinder Rayat

Hi Douglas,

Happy New Year.

I have got the query to work. From the form I enter the priority number and
have a button to open the report, and it correctly displays all records with
that priority.

From your suggestions, I have used a value list 1-5 for priorities and the
piece of VBA code from Access Web to display (All) as an option.

Private Sub Form_Open(Cancel As Integer)
With Me.Combo4
.RowSourceType = "Value List"
.RowSource = "(All);" & .RowSource
End With
End Sub

However when attempting to display all records from the form, I get an error
message stating that "This expression is typed incorrectly, or is too complex
to be evaluated. For example a numeric expression may contain too many
complicated elements.... "

Am I missing something to display all records or did you expect it to work
from what I have done so far?

Thanks again,

B/


Douglas J. Steele said:
And just in case I've misinterpretted "still having trouble bringing up the
combo box", hopefully you noticed my comment to "Make sure that the form is
open when the query runs."

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
Hi Douglas,

Thanks for this.

I have added All to the query but I'm still having trouble bringing up the
combo box.

Do you want me to use add the first line in criteria and the second line
in
or?
so...

Criteria: < [Forms]![frmPriority]![Combo4]
or: ([Forms]![frmPriority]![Combo4] = "All")

Like this ?

B/


Douglas J. Steele said:
You cannot make Access prompt you with a combo box. However, you can
create
an unbound form with a combo box that has four values: 1, 2, 3 and All
(if
you're getting the numbers from a table rather than hard-coding them, see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web" for how
to
add "All" to your query)

Change your query's criteria to

< [Forms]![NameOfForm]![NameOfComboBox) OR
([Forms]![NameOfForm]![NameOfComboBox) = "All")

Make sure that the form is open when the query runs: Access will not open
the form for you either.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message Hi,

I have a report which opens a query, based on the priority number (1,2
or
3).

In the query criterira for Priority I have the following.

<[Show all CP with priority <=]

This brings up a prompt box when I open the report where I type 1, 2 or
3
to
bring up the records with that priority.

I want to change the caption to a combo box where I can select 1, 2, or
3
rather than typing it in, and also have the option to display ALL
records.

Can anyone help please?

Thanks,

B/
 
D

Douglas J. Steele

What's the SQL for the query that the report's based on?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
Hi Douglas,

Happy New Year.

I have got the query to work. From the form I enter the priority number
and
have a button to open the report, and it correctly displays all records
with
that priority.

From your suggestions, I have used a value list 1-5 for priorities and the
piece of VBA code from Access Web to display (All) as an option.

Private Sub Form_Open(Cancel As Integer)
With Me.Combo4
.RowSourceType = "Value List"
.RowSource = "(All);" & .RowSource
End With
End Sub

However when attempting to display all records from the form, I get an
error
message stating that "This expression is typed incorrectly, or is too
complex
to be evaluated. For example a numeric expression may contain too many
complicated elements.... "

Am I missing something to display all records or did you expect it to work
from what I have done so far?

Thanks again,

B/


Douglas J. Steele said:
And just in case I've misinterpretted "still having trouble bringing up
the
combo box", hopefully you noticed my comment to "Make sure that the form
is
open when the query runs."

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
Hi Douglas,

Thanks for this.

I have added All to the query but I'm still having trouble bringing up
the
combo box.

Do you want me to use add the first line in criteria and the second
line
in
or?
so...

Criteria: < [Forms]![frmPriority]![Combo4]
or: ([Forms]![frmPriority]![Combo4] = "All")

Like this ?

B/


:

You cannot make Access prompt you with a combo box. However, you can
create
an unbound form with a combo box that has four values: 1, 2, 3 and All
(if
you're getting the numbers from a table rather than hard-coding them,
see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web" for
how
to
add "All" to your query)

Change your query's criteria to

< [Forms]![NameOfForm]![NameOfComboBox) OR
([Forms]![NameOfForm]![NameOfComboBox) = "All")

Make sure that the form is open when the query runs: Access will not
open
the form for you either.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message Hi,

I have a report which opens a query, based on the priority number
(1,2
or
3).

In the query criterira for Priority I have the following.

<[Show all CP with priority <=]

This brings up a prompt box when I open the report where I type 1, 2
or
3
to
bring up the records with that priority.

I want to change the caption to a combo box where I can select 1, 2,
or
3
rather than typing it in, and also have the option to display ALL
records.

Can anyone help please?

Thanks,

B/
 
B

Bhupinder Rayat

The report is just basic it returns all fields of a query which is simply
just a selection of fields from 7 tables, so the SQL is quite large. Here it
is....

SELECT tblCounterparty.Name, tblDocument.[Document Name],
tblCounterpartyDocument.[Signed Date], tblType.[Type Name],
tblDocumentStatus.[Action Date], tblDocumentStatus.[Start Date],
tblDocumentStatus.Comment, tblCounterparty.[Commericial Contact],
tblDocsNegotiator.[Docs Negotiator Name], tblCreditOfficer.[Credit Officer
Name], tblCounterparty.Priority, tblDocumentStatus.[Completed Date]
FROM tblDocsNegotiator RIGHT JOIN ((tblDocument RIGHT JOIN (tblCreditOfficer
RIGHT JOIN (tblCounterparty INNER JOIN tblCounterpartyDocument ON
tblCounterparty.[CounterParty ID] = tblCounterpartyDocument.[CounterParty
ID]) ON tblCreditOfficer.[Credit Officer ID] = tblCounterparty.[Credit
Officer ID]) ON tblDocument.[Document ID] = tblCounterpartyDocument.[Document
ID]) LEFT JOIN (tblType RIGHT JOIN tblDocumentStatus ON tblType.[Type ID] =
tblDocumentStatus.[Type ID]) ON (tblCounterpartyDocument.[Document ID] =
tblDocumentStatus.[Document ID]) AND (tblCounterpartyDocument.[CounterParty
ID] = tblDocumentStatus.[CounterParty ID])) ON tblDocsNegotiator.[Docs
Negotiator ID] = tblCounterparty.[Docs Negotiator ID]
WHERE (((tblCounterparty.Name) Not Like "Markus*") AND
((tblCounterpartyDocument.[Signed Date]) Is Null) AND
((tblCounterparty.Priority)=[Forms]![frmPriority]![Combo4]) AND
((tblDocumentStatus.[Completed Date]) Is Null)) OR (((tblCounterparty.Name)
Not Like "Markus*") AND ((tblCounterpartyDocument.[Signed Date]) Is Null) AND
((tblDocumentStatus.[Completed Date]) Is Null) AND
(([Forms]![frmPriority]![Combo4])="All"))
ORDER BY tblCounterparty.Name, tblCounterparty.Priority;


Thanks,

B/
Douglas J. Steele said:
What's the SQL for the query that the report's based on?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
Hi Douglas,

Happy New Year.

I have got the query to work. From the form I enter the priority number
and
have a button to open the report, and it correctly displays all records
with
that priority.

From your suggestions, I have used a value list 1-5 for priorities and the
piece of VBA code from Access Web to display (All) as an option.

Private Sub Form_Open(Cancel As Integer)
With Me.Combo4
.RowSourceType = "Value List"
.RowSource = "(All);" & .RowSource
End With
End Sub

However when attempting to display all records from the form, I get an
error
message stating that "This expression is typed incorrectly, or is too
complex
to be evaluated. For example a numeric expression may contain too many
complicated elements.... "

Am I missing something to display all records or did you expect it to work
from what I have done so far?

Thanks again,

B/


Douglas J. Steele said:
And just in case I've misinterpretted "still having trouble bringing up
the
combo box", hopefully you noticed my comment to "Make sure that the form
is
open when the query runs."

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message Hi Douglas,

Thanks for this.

I have added All to the query but I'm still having trouble bringing up
the
combo box.

Do you want me to use add the first line in criteria and the second
line
in
or?
so...

Criteria: < [Forms]![frmPriority]![Combo4]
or: ([Forms]![frmPriority]![Combo4] = "All")

Like this ?

B/


:

You cannot make Access prompt you with a combo box. However, you can
create
an unbound form with a combo box that has four values: 1, 2, 3 and All
(if
you're getting the numbers from a table rather than hard-coding them,
see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web" for
how
to
add "All" to your query)

Change your query's criteria to

< [Forms]![NameOfForm]![NameOfComboBox) OR
([Forms]![NameOfForm]![NameOfComboBox) = "All")

Make sure that the form is open when the query runs: Access will not
open
the form for you either.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message Hi,

I have a report which opens a query, based on the priority number
(1,2
or
3).

In the query criterira for Priority I have the following.

<[Show all CP with priority <=]

This brings up a prompt box when I open the report where I type 1, 2
or
3
to
bring up the records with that priority.

I want to change the caption to a combo box where I can select 1, 2,
or
3
rather than typing it in, and also have the option to display ALL
records.

Can anyone help please?

Thanks,

B/
 
D

Douglas J. Steele

Try to simplify your Where clause:

WHERE tblCounterparty.Name Not Like "Markus*" AND
tblCounterpartyDocument.[Signed Date] Is Null AND
tblDocumentStatus.[Completed Date] Is Null AND
(tblCounterparty.Priority=[Forms]![frmPriority]![Combo4] OR
Nz([Forms]![frmPriority]![Combo4], "All")="All")

I've added the Nz in there to handle the case where they haven't selected
anything from the combo box. (I've defaulted nothing selected to mean the
same as select all. You can change that if you need to...)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
The report is just basic it returns all fields of a query which is simply
just a selection of fields from 7 tables, so the SQL is quite large. Here
it
is....

SELECT tblCounterparty.Name, tblDocument.[Document Name],
tblCounterpartyDocument.[Signed Date], tblType.[Type Name],
tblDocumentStatus.[Action Date], tblDocumentStatus.[Start Date],
tblDocumentStatus.Comment, tblCounterparty.[Commericial Contact],
tblDocsNegotiator.[Docs Negotiator Name], tblCreditOfficer.[Credit Officer
Name], tblCounterparty.Priority, tblDocumentStatus.[Completed Date]
FROM tblDocsNegotiator RIGHT JOIN ((tblDocument RIGHT JOIN
(tblCreditOfficer
RIGHT JOIN (tblCounterparty INNER JOIN tblCounterpartyDocument ON
tblCounterparty.[CounterParty ID] = tblCounterpartyDocument.[CounterParty
ID]) ON tblCreditOfficer.[Credit Officer ID] = tblCounterparty.[Credit
Officer ID]) ON tblDocument.[Document ID] =
tblCounterpartyDocument.[Document
ID]) LEFT JOIN (tblType RIGHT JOIN tblDocumentStatus ON tblType.[Type ID]
=
tblDocumentStatus.[Type ID]) ON (tblCounterpartyDocument.[Document ID] =
tblDocumentStatus.[Document ID]) AND
(tblCounterpartyDocument.[CounterParty
ID] = tblDocumentStatus.[CounterParty ID])) ON tblDocsNegotiator.[Docs
Negotiator ID] = tblCounterparty.[Docs Negotiator ID]
WHERE (((tblCounterparty.Name) Not Like "Markus*") AND
((tblCounterpartyDocument.[Signed Date]) Is Null) AND
((tblCounterparty.Priority)=[Forms]![frmPriority]![Combo4]) AND
((tblDocumentStatus.[Completed Date]) Is Null)) OR
(((tblCounterparty.Name)
Not Like "Markus*") AND ((tblCounterpartyDocument.[Signed Date]) Is Null)
AND
((tblDocumentStatus.[Completed Date]) Is Null) AND
(([Forms]![frmPriority]![Combo4])="All"))
ORDER BY tblCounterparty.Name, tblCounterparty.Priority;


Thanks,

B/
Douglas J. Steele said:
What's the SQL for the query that the report's based on?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
Hi Douglas,

Happy New Year.

I have got the query to work. From the form I enter the priority number
and
have a button to open the report, and it correctly displays all records
with
that priority.

From your suggestions, I have used a value list 1-5 for priorities and
the
piece of VBA code from Access Web to display (All) as an option.

Private Sub Form_Open(Cancel As Integer)
With Me.Combo4
.RowSourceType = "Value List"
.RowSource = "(All);" & .RowSource
End With
End Sub

However when attempting to display all records from the form, I get an
error
message stating that "This expression is typed incorrectly, or is too
complex
to be evaluated. For example a numeric expression may contain too many
complicated elements.... "

Am I missing something to display all records or did you expect it to
work
from what I have done so far?

Thanks again,

B/


:

And just in case I've misinterpretted "still having trouble bringing
up
the
combo box", hopefully you noticed my comment to "Make sure that the
form
is
open when the query runs."

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message Hi Douglas,

Thanks for this.

I have added All to the query but I'm still having trouble bringing
up
the
combo box.

Do you want me to use add the first line in criteria and the second
line
in
or?
so...

Criteria: < [Forms]![frmPriority]![Combo4]
or: ([Forms]![frmPriority]![Combo4] = "All")

Like this ?

B/


:

You cannot make Access prompt you with a combo box. However, you
can
create
an unbound form with a combo box that has four values: 1, 2, 3 and
All
(if
you're getting the numbers from a table rather than hard-coding
them,
see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web"
for
how
to
add "All" to your query)

Change your query's criteria to

< [Forms]![NameOfForm]![NameOfComboBox) OR
([Forms]![NameOfForm]![NameOfComboBox) = "All")

Make sure that the form is open when the query runs: Access will
not
open
the form for you either.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


in
message Hi,

I have a report which opens a query, based on the priority number
(1,2
or
3).

In the query criterira for Priority I have the following.

<[Show all CP with priority <=]

This brings up a prompt box when I open the report where I type
1, 2
or
3
to
bring up the records with that priority.

I want to change the caption to a combo box where I can select 1,
2,
or
3
rather than typing it in, and also have the option to display ALL
records.

Can anyone help please?

Thanks,

B/
 
B

Bhupinder Rayat

Hi Doug,

My query is good now, I have 2 combo boxes to select from. It works when you
have a selection from both boxes, but doesn't work if one combo box is an
"all".

WHERE (((tblCounterparty.Name) Not Like "Markus*")
AND ((tblCounterpartyDocument.[Signed Date]) Is Null)
AND ((tblCounterparty.PriorityID)=[forms]![frmPriority]![Combo4])
AND ((tblDocumentStatus.TypeID)=[forms]![frmPriority]![cmbTypeName]))
OR (((0)=[forms]![frmPriority]![Combo4]
Or (0)=[forms]![frmPriority]![cmbTypeName]))
ORDER BY tblCounterparty.Name, tblCounterparty.Priority;

the "all" selection works as follows..
Priority
SELECT tblPriority.PriorityID, tblPriority.Priority FROM tblPriority UNION
SELECT 0 As PriorityID,"(All)" As Priority FROM tblPriority ORDER BY Priority;

Type
SELECT tblType.TypeID, tblType.TypeName FROM tblType UNION SELECT 0 As
TypeID,"(All)" As TypeName FROM tblType ORDER BY tblType.[TypeID];

I can kind of see why it doesn't work, because once you select and "all" in
one combo box, it ignores the other AND selection, but I can't quite see how
to fix it.

Maybe embed the union queries a sub-queries of the main WHERE claus? any
ideas?

Thanks for all your help!

B/

Douglas J. Steele said:
Try to simplify your Where clause:

WHERE tblCounterparty.Name Not Like "Markus*" AND
tblCounterpartyDocument.[Signed Date] Is Null AND
tblDocumentStatus.[Completed Date] Is Null AND
(tblCounterparty.Priority=[Forms]![frmPriority]![Combo4] OR
Nz([Forms]![frmPriority]![Combo4], "All")="All")

I've added the Nz in there to handle the case where they haven't selected
anything from the combo box. (I've defaulted nothing selected to mean the
same as select all. You can change that if you need to...)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
The report is just basic it returns all fields of a query which is simply
just a selection of fields from 7 tables, so the SQL is quite large. Here
it
is....

SELECT tblCounterparty.Name, tblDocument.[Document Name],
tblCounterpartyDocument.[Signed Date], tblType.[Type Name],
tblDocumentStatus.[Action Date], tblDocumentStatus.[Start Date],
tblDocumentStatus.Comment, tblCounterparty.[Commericial Contact],
tblDocsNegotiator.[Docs Negotiator Name], tblCreditOfficer.[Credit Officer
Name], tblCounterparty.Priority, tblDocumentStatus.[Completed Date]
FROM tblDocsNegotiator RIGHT JOIN ((tblDocument RIGHT JOIN
(tblCreditOfficer
RIGHT JOIN (tblCounterparty INNER JOIN tblCounterpartyDocument ON
tblCounterparty.[CounterParty ID] = tblCounterpartyDocument.[CounterParty
ID]) ON tblCreditOfficer.[Credit Officer ID] = tblCounterparty.[Credit
Officer ID]) ON tblDocument.[Document ID] =
tblCounterpartyDocument.[Document
ID]) LEFT JOIN (tblType RIGHT JOIN tblDocumentStatus ON tblType.[Type ID]
=
tblDocumentStatus.[Type ID]) ON (tblCounterpartyDocument.[Document ID] =
tblDocumentStatus.[Document ID]) AND
(tblCounterpartyDocument.[CounterParty
ID] = tblDocumentStatus.[CounterParty ID])) ON tblDocsNegotiator.[Docs
Negotiator ID] = tblCounterparty.[Docs Negotiator ID]
WHERE (((tblCounterparty.Name) Not Like "Markus*") AND
((tblCounterpartyDocument.[Signed Date]) Is Null) AND
((tblCounterparty.Priority)=[Forms]![frmPriority]![Combo4]) AND
((tblDocumentStatus.[Completed Date]) Is Null)) OR
(((tblCounterparty.Name)
Not Like "Markus*") AND ((tblCounterpartyDocument.[Signed Date]) Is Null)
AND
((tblDocumentStatus.[Completed Date]) Is Null) AND
(([Forms]![frmPriority]![Combo4])="All"))
ORDER BY tblCounterparty.Name, tblCounterparty.Priority;


Thanks,

B/
Douglas J. Steele said:
What's the SQL for the query that the report's based on?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message Hi Douglas,

Happy New Year.

I have got the query to work. From the form I enter the priority number
and
have a button to open the report, and it correctly displays all records
with
that priority.

From your suggestions, I have used a value list 1-5 for priorities and
the
piece of VBA code from Access Web to display (All) as an option.

Private Sub Form_Open(Cancel As Integer)
With Me.Combo4
.RowSourceType = "Value List"
.RowSource = "(All);" & .RowSource
End With
End Sub

However when attempting to display all records from the form, I get an
error
message stating that "This expression is typed incorrectly, or is too
complex
to be evaluated. For example a numeric expression may contain too many
complicated elements.... "

Am I missing something to display all records or did you expect it to
work
from what I have done so far?

Thanks again,

B/


:

And just in case I've misinterpretted "still having trouble bringing
up
the
combo box", hopefully you noticed my comment to "Make sure that the
form
is
open when the query runs."

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message Hi Douglas,

Thanks for this.

I have added All to the query but I'm still having trouble bringing
up
the
combo box.

Do you want me to use add the first line in criteria and the second
line
in
or?
so...

Criteria: < [Forms]![frmPriority]![Combo4]
or: ([Forms]![frmPriority]![Combo4] = "All")

Like this ?

B/


:

You cannot make Access prompt you with a combo box. However, you
can
create
an unbound form with a combo box that has four values: 1, 2, 3 and
All
(if
you're getting the numbers from a table rather than hard-coding
them,
see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web"
for
how
to
add "All" to your query)

Change your query's criteria to

< [Forms]![NameOfForm]![NameOfComboBox) OR
([Forms]![NameOfForm]![NameOfComboBox) = "All")

Make sure that the form is open when the query runs: Access will
not
open
the form for you either.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


in
message Hi,

I have a report which opens a query, based on the priority number
(1,2
or
3).

In the query criterira for Priority I have the following.

<[Show all CP with priority <=]

This brings up a prompt box when I open the report where I type
1, 2
or
3
to
bring up the records with that priority.

I want to change the caption to a combo box where I can select 1,
2,
or
3
rather than typing it in, and also have the option to display ALL
records.

Can anyone help please?

Thanks,

B/
 
J

John Spencer

Try rearranging the criteria to the following. I have spaced out the
criteria so it is more obvious how the various clauses are being grouped.

WHERE tblCounterparty.Name Not Like "Markus*"
AND tblCounterpartyDocument.[Signed Date] Is Null
AND (
tblCounterparty.PriorityID=[forms]![frmPriority]![Combo4]
OR [forms]![frmPriority]![Combo4] = 0
)
AND (
tblDocumentStatus.TypeID=[forms]![frmPriority]![cmbTypeName]
OR[forms]![frmPriority]![cmbTypeName] =0
)

Note that once you save, close, and reopen the above that Access will add a
lot of parentheses to the above.
--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Bhupinder Rayat said:
Hi Doug,

My query is good now, I have 2 combo boxes to select from. It works when
you
have a selection from both boxes, but doesn't work if one combo box is an
"all".

WHERE (((tblCounterparty.Name) Not Like "Markus*")
AND ((tblCounterpartyDocument.[Signed Date]) Is Null)
AND ((tblCounterparty.PriorityID)=[forms]![frmPriority]![Combo4])
AND ((tblDocumentStatus.TypeID)=[forms]![frmPriority]![cmbTypeName]))
OR (((0)=[forms]![frmPriority]![Combo4]
Or (0)=[forms]![frmPriority]![cmbTypeName]))
ORDER BY tblCounterparty.Name, tblCounterparty.Priority;

the "all" selection works as follows..
Priority
SELECT tblPriority.PriorityID, tblPriority.Priority FROM tblPriority UNION
SELECT 0 As PriorityID,"(All)" As Priority FROM tblPriority ORDER BY
Priority;

Type
SELECT tblType.TypeID, tblType.TypeName FROM tblType UNION SELECT 0 As
TypeID,"(All)" As TypeName FROM tblType ORDER BY tblType.[TypeID];

I can kind of see why it doesn't work, because once you select and "all"
in
one combo box, it ignores the other AND selection, but I can't quite see
how
to fix it.

Maybe embed the union queries a sub-queries of the main WHERE claus? any
ideas?

Thanks for all your help!

B/

Douglas J. Steele said:
Try to simplify your Where clause:

WHERE tblCounterparty.Name Not Like "Markus*" AND
tblCounterpartyDocument.[Signed Date] Is Null AND
tblDocumentStatus.[Completed Date] Is Null AND
(tblCounterparty.Priority=[Forms]![frmPriority]![Combo4] OR
Nz([Forms]![frmPriority]![Combo4], "All")="All")

I've added the Nz in there to handle the case where they haven't selected
anything from the combo box. (I've defaulted nothing selected to mean the
same as select all. You can change that if you need to...)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bhupinder Rayat said:
The report is just basic it returns all fields of a query which is
simply
just a selection of fields from 7 tables, so the SQL is quite large.
Here
it
is....

SELECT tblCounterparty.Name, tblDocument.[Document Name],
tblCounterpartyDocument.[Signed Date], tblType.[Type Name],
tblDocumentStatus.[Action Date], tblDocumentStatus.[Start Date],
tblDocumentStatus.Comment, tblCounterparty.[Commericial Contact],
tblDocsNegotiator.[Docs Negotiator Name], tblCreditOfficer.[Credit
Officer
Name], tblCounterparty.Priority, tblDocumentStatus.[Completed Date]
FROM tblDocsNegotiator RIGHT JOIN ((tblDocument RIGHT JOIN
(tblCreditOfficer
RIGHT JOIN (tblCounterparty INNER JOIN tblCounterpartyDocument ON
tblCounterparty.[CounterParty ID] =
tblCounterpartyDocument.[CounterParty
ID]) ON tblCreditOfficer.[Credit Officer ID] = tblCounterparty.[Credit
Officer ID]) ON tblDocument.[Document ID] =
tblCounterpartyDocument.[Document
ID]) LEFT JOIN (tblType RIGHT JOIN tblDocumentStatus ON tblType.[Type
ID]
=
tblDocumentStatus.[Type ID]) ON (tblCounterpartyDocument.[Document ID]
=
tblDocumentStatus.[Document ID]) AND
(tblCounterpartyDocument.[CounterParty
ID] = tblDocumentStatus.[CounterParty ID])) ON tblDocsNegotiator.[Docs
Negotiator ID] = tblCounterparty.[Docs Negotiator ID]
WHERE (((tblCounterparty.Name) Not Like "Markus*") AND
((tblCounterpartyDocument.[Signed Date]) Is Null) AND
((tblCounterparty.Priority)=[Forms]![frmPriority]![Combo4]) AND
((tblDocumentStatus.[Completed Date]) Is Null)) OR
(((tblCounterparty.Name)
Not Like "Markus*") AND ((tblCounterpartyDocument.[Signed Date]) Is
Null)
AND
((tblDocumentStatus.[Completed Date]) Is Null) AND
(([Forms]![frmPriority]![Combo4])="All"))
ORDER BY tblCounterparty.Name, tblCounterparty.Priority;


Thanks,

B/
:

What's the SQL for the query that the report's based on?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message Hi Douglas,

Happy New Year.

I have got the query to work. From the form I enter the priority
number
and
have a button to open the report, and it correctly displays all
records
with
that priority.

From your suggestions, I have used a value list 1-5 for priorities
and
the
piece of VBA code from Access Web to display (All) as an option.

Private Sub Form_Open(Cancel As Integer)
With Me.Combo4
.RowSourceType = "Value List"
.RowSource = "(All);" & .RowSource
End With
End Sub

However when attempting to display all records from the form, I get
an
error
message stating that "This expression is typed incorrectly, or is
too
complex
to be evaluated. For example a numeric expression may contain too
many
complicated elements.... "

Am I missing something to display all records or did you expect it
to
work
from what I have done so far?

Thanks again,

B/


:

And just in case I've misinterpretted "still having trouble
bringing
up
the
combo box", hopefully you noticed my comment to "Make sure that the
form
is
open when the query runs."

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


in
message Hi Douglas,

Thanks for this.

I have added All to the query but I'm still having trouble
bringing
up
the
combo box.

Do you want me to use add the first line in criteria and the
second
line
in
or?
so...

Criteria: < [Forms]![frmPriority]![Combo4]
or: ([Forms]![frmPriority]![Combo4] = "All")

Like this ?

B/


:

You cannot make Access prompt you with a combo box. However, you
can
create
an unbound form with a combo box that has four values: 1, 2, 3
and
All
(if
you're getting the numbers from a table rather than hard-coding
them,
see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web"
for
how
to
add "All" to your query)

Change your query's criteria to

< [Forms]![NameOfForm]![NameOfComboBox) OR
([Forms]![NameOfForm]![NameOfComboBox) = "All")

Make sure that the form is open when the query runs: Access will
not
open
the form for you either.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


"Bhupinder Rayat" <[email protected]>
wrote
in
message
Hi,

I have a report which opens a query, based on the priority
number
(1,2
or
3).

In the query criterira for Priority I have the following.

<[Show all CP with priority <=]

This brings up a prompt box when I open the report where I
type
1, 2
or
3
to
bring up the records with that priority.

I want to change the caption to a combo box where I can select
1,
2,
or
3
rather than typing it in, and also have the option to display
ALL
records.

Can anyone help please?

Thanks,

B/
 
B

Bhupinder Rayat

Hi John,

You are the man!

It works great, and yep it does expand out to give all 4 possible
combintions that you choose from the 2 combo boxes: - (type and priority,
type and all, all and priority, all and all).

WHERE (((tblCounterparty.Name) Not Like "Markus*")
AND ((tblCounterpartyDocument.[Signed Date]) Is Null)
AND ((tblCounterparty.PriorityID)=[forms]![frmPriority]![Combo4])
AND ((tblDocumentStatus.TypeID)=[forms]![frmPriority]![cmbTypeName]))
OR (((tblCounterparty.Name) Not Like "Markus*")

AND ((tblCounterpartyDocument.[Signed Date]) Is Null)
AND ((tblDocumentStatus.TypeID)=[forms]![frmPriority]![cmbTypeName])
AND (([forms]![frmPriority]![Combo4])=0))
OR (((tblCounterparty.Name) Not Like "Markus*")

AND ((tblCounterpartyDocument.[Signed Date]) Is Null)
AND ((tblCounterparty.PriorityID)=[forms]![frmPriority]![Combo4])
AND (([forms]![frmPriority]![cmbTypeName])=0))
OR (((tblCounterparty.Name) Not Like "Markus*")

AND ((tblCounterpartyDocument.[Signed Date]) Is Null)
AND (([forms]![frmPriority]![Combo4])=0)
AND (([forms]![frmPriority]![cmbTypeName])=0))
ORDER BY tblType.TypeName, tblCounterparty.Name, tblCounterparty.Priority;


Thank you so much,

B/


John Spencer said:
Try rearranging the criteria to the following. I have spaced out the
criteria so it is more obvious how the various clauses are being grouped.

WHERE tblCounterparty.Name Not Like "Markus*"
AND tblCounterpartyDocument.[Signed Date] Is Null
AND (
tblCounterparty.PriorityID=[forms]![frmPriority]![Combo4]
OR [forms]![frmPriority]![Combo4] = 0
)
AND (
tblDocumentStatus.TypeID=[forms]![frmPriority]![cmbTypeName]
OR[forms]![frmPriority]![cmbTypeName] =0
)

Note that once you save, close, and reopen the above that Access will add a
lot of parentheses to the above.
--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Bhupinder Rayat said:
Hi Doug,

My query is good now, I have 2 combo boxes to select from. It works when
you
have a selection from both boxes, but doesn't work if one combo box is an
"all".

WHERE (((tblCounterparty.Name) Not Like "Markus*")
AND ((tblCounterpartyDocument.[Signed Date]) Is Null)
AND ((tblCounterparty.PriorityID)=[forms]![frmPriority]![Combo4])
AND ((tblDocumentStatus.TypeID)=[forms]![frmPriority]![cmbTypeName]))
OR (((0)=[forms]![frmPriority]![Combo4]
Or (0)=[forms]![frmPriority]![cmbTypeName]))
ORDER BY tblCounterparty.Name, tblCounterparty.Priority;

the "all" selection works as follows..
Priority
SELECT tblPriority.PriorityID, tblPriority.Priority FROM tblPriority UNION
SELECT 0 As PriorityID,"(All)" As Priority FROM tblPriority ORDER BY
Priority;

Type
SELECT tblType.TypeID, tblType.TypeName FROM tblType UNION SELECT 0 As
TypeID,"(All)" As TypeName FROM tblType ORDER BY tblType.[TypeID];

I can kind of see why it doesn't work, because once you select and "all"
in
one combo box, it ignores the other AND selection, but I can't quite see
how
to fix it.

Maybe embed the union queries a sub-queries of the main WHERE claus? any
ideas?

Thanks for all your help!

B/

Douglas J. Steele said:
Try to simplify your Where clause:

WHERE tblCounterparty.Name Not Like "Markus*" AND
tblCounterpartyDocument.[Signed Date] Is Null AND
tblDocumentStatus.[Completed Date] Is Null AND
(tblCounterparty.Priority=[Forms]![frmPriority]![Combo4] OR
Nz([Forms]![frmPriority]![Combo4], "All")="All")

I've added the Nz in there to handle the case where they haven't selected
anything from the combo box. (I've defaulted nothing selected to mean the
same as select all. You can change that if you need to...)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message The report is just basic it returns all fields of a query which is
simply
just a selection of fields from 7 tables, so the SQL is quite large.
Here
it
is....

SELECT tblCounterparty.Name, tblDocument.[Document Name],
tblCounterpartyDocument.[Signed Date], tblType.[Type Name],
tblDocumentStatus.[Action Date], tblDocumentStatus.[Start Date],
tblDocumentStatus.Comment, tblCounterparty.[Commericial Contact],
tblDocsNegotiator.[Docs Negotiator Name], tblCreditOfficer.[Credit
Officer
Name], tblCounterparty.Priority, tblDocumentStatus.[Completed Date]
FROM tblDocsNegotiator RIGHT JOIN ((tblDocument RIGHT JOIN
(tblCreditOfficer
RIGHT JOIN (tblCounterparty INNER JOIN tblCounterpartyDocument ON
tblCounterparty.[CounterParty ID] =
tblCounterpartyDocument.[CounterParty
ID]) ON tblCreditOfficer.[Credit Officer ID] = tblCounterparty.[Credit
Officer ID]) ON tblDocument.[Document ID] =
tblCounterpartyDocument.[Document
ID]) LEFT JOIN (tblType RIGHT JOIN tblDocumentStatus ON tblType.[Type
ID]
=
tblDocumentStatus.[Type ID]) ON (tblCounterpartyDocument.[Document ID]
=
tblDocumentStatus.[Document ID]) AND
(tblCounterpartyDocument.[CounterParty
ID] = tblDocumentStatus.[CounterParty ID])) ON tblDocsNegotiator.[Docs
Negotiator ID] = tblCounterparty.[Docs Negotiator ID]
WHERE (((tblCounterparty.Name) Not Like "Markus*") AND
((tblCounterpartyDocument.[Signed Date]) Is Null) AND
((tblCounterparty.Priority)=[Forms]![frmPriority]![Combo4]) AND
((tblDocumentStatus.[Completed Date]) Is Null)) OR
(((tblCounterparty.Name)
Not Like "Markus*") AND ((tblCounterpartyDocument.[Signed Date]) Is
Null)
AND
((tblDocumentStatus.[Completed Date]) Is Null) AND
(([Forms]![frmPriority]![Combo4])="All"))
ORDER BY tblCounterparty.Name, tblCounterparty.Priority;


Thanks,

B/
:

What's the SQL for the query that the report's based on?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message Hi Douglas,

Happy New Year.

I have got the query to work. From the form I enter the priority
number
and
have a button to open the report, and it correctly displays all
records
with
that priority.

From your suggestions, I have used a value list 1-5 for priorities
and
the
piece of VBA code from Access Web to display (All) as an option.

Private Sub Form_Open(Cancel As Integer)
With Me.Combo4
.RowSourceType = "Value List"
.RowSource = "(All);" & .RowSource
End With
End Sub

However when attempting to display all records from the form, I get
an
error
message stating that "This expression is typed incorrectly, or is
too
complex
to be evaluated. For example a numeric expression may contain too
many
complicated elements.... "

Am I missing something to display all records or did you expect it
to
work
from what I have done so far?

Thanks again,

B/


:

And just in case I've misinterpretted "still having trouble
bringing
up
the
combo box", hopefully you noticed my comment to "Make sure that the
form
is
open when the query runs."

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


in
message Hi Douglas,

Thanks for this.

I have added All to the query but I'm still having trouble
bringing
up
the
combo box.

Do you want me to use add the first line in criteria and the
second
line
in
or?
so...

Criteria: < [Forms]![frmPriority]![Combo4]
or: ([Forms]![frmPriority]![Combo4] = "All")

Like this ?

B/


:

You cannot make Access prompt you with a combo box. However, you
can
create
an unbound form with a combo box that has four values: 1, 2, 3
and
All
(if
you're getting the numbers from a table rather than hard-coding
them,
see
http://www.mvps.org/access/forms/frm0043.htm at "The Access Web"
for
how
to
add "All" to your query)

Change your query's criteria to

< [Forms]![NameOfForm]![NameOfComboBox) OR
([Forms]![NameOfForm]![NameOfComboBox) = "All")

Make sure that the form is open when the query runs: Access will
not
open
the form for you either.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


"Bhupinder Rayat" <[email protected]>
wrote
in
message
Hi,

I have a report which opens a query, based on the priority
number
(1,2
or
3).

In the query criterira for Priority I have the following.

<[Show all CP with priority <=]

This brings up a prompt box when I open the report where I
type
1, 2
or
3
to
bring up the records with that priority.

I want to change the caption to a combo box where I can select
1,
2,
or
3
rather than typing it in, and also have the option to display
ALL
records.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Creating an "if then" in a query 2
Adding <ALL> to a combo box 6
Criteria change 1
Subquery Issue 1 5
Combo Box 1
query relelated to 2 combo boxes 2
Combo box parameter report 1
IIF statement in query 3

Top