Pass parameter (from a form) to a report query

sarahb845

Registered User.
Local time
Today, 13:18
Joined
Jun 19, 2002
Messages
43
I am trying to pass a combobox parameter from a form to a query, which then runs the report. Generally I have not had a problem with this, until now.

Form:
The combobox, called [cboOverdue], has a Row Source Type of Value List, with "No" and "Yes" as the 2 items in the Row Source. I have set the default value is "No".

Basically, the parameter is "Only include overdue reviews?". If the user selects "Yes", then I only want the overdue performance reviews; if the user selects "No", I want the report to show ALL reviews.

When I select "Yes" in the [cboOverdue] combobox, the report correctly shows only the records with overdue reviews. However, when I select "No", I get no data on the report.


Query:
The data for the field [ReviewOverdue] is either " " or "Yes".

Tried this criteria for the field:
IIF([Forms]![frmReports]![frmReportsSUB].[Form]![cboOverdue] = "No", "*", [Forms]![frmReports]![frmReportsSUB].[Form]![cboOverdue])

I have also tried:
IIF([Forms]![frmReports]![frmReportsSUB].[Form]![cboOverdue] = "Yes", [Forms]![frmReports]![frmReportsSUB].[Form]![cboOverdue])


I'm not sure what else to try???
 
You wrote
<<
Basically, the parameter is "Only include overdue reviews?". If the user selects "Yes", then I only want the overdue performance reviews; if the user selects "No", I want the report to show ALL reviews.

When I select "Yes" in the [cboOverdue] combobox, the report correctly shows only the records with overdue reviews. However, when I select "No", I get no data on the report.
>>

So, you want either "Yes" in column something or everything.

In that case a simple but inflexible solution is:
2 queries and 2 reports,
one query selects "Yes" the other selects everything.


RichM
 
I have more parameters than just that one.

Should I add those to the OpenReport method WHERE, or leave them in the query as is????
 
On a related topic

I have a query for a report, as well. I decided to build the where clause as has been noted here. Now, when I attempt to open the report, I get a prompt asking me for the value for the criterion I just set up!

It's like this:

stWhere = "[tbl].[field1] = " & lstThis.value
DoCmd.OpenReport rptName, acViewPreview, , stWhere

The prompt is asking for tbl.field1

Thanks in advance.
 
If field1 is the correct name, then you should try:

Code:
stWhere = "[field1] = " & lstThis.value 
DoCmd.OpenReport rptName, acViewPreview, , stWhere


Brad.
 
[field1] has to be qualified, since there are multiple tables being joined in the query.
 

Users who are viewing this thread

Back
Top Bottom