I have a report that does an aggregate (Total Charges by Person), and I want to apply dynamic filters (user-entered on a form) that refer to fields not in the report (Ex: Date, Type).
In SQL, it might look like this:
SELECT [Person].[FullName], SUM([Charge].[Total]) AS TotalAmount
FROM [Person] INNER JOIN [Charge] ON [Person].[PersonID] = [Charge].[PersonID]
WHERE [Charge].[ChargeType] = "Professional Fees"
AND [Charge].[ChargeDate] Between #01/01/2011# And #12/31/2011#
(The form allows the user to choose the type and date.)
When I call OpenReport, Access prompts the user to supply values for those fields not in the SELECT clause ([Charge].[ChargeType] and [Charge].[ChargeDate]), as if the fields were parameters.
The OpenReport call looks like this:
DoCmd.OpenReport "Summarized Charges by Salesperson", acViewPreview, strSelect
(where I dynamically generate the SQL you see above)
If I run the SQL directly in an Access query, I don't get the prompts (in case someone thought I might have misspelled the field names by accident).
I even tried revising the OpenReport call to this, splitting out the Where clause as a separate string, but I get the same result:
DoCmd.OpenReport "Summarized Charges by Salesperson", acViewPreview, strSelectWithoutWhere, strWhere
How can I define the report or SQL so that it won't prompt for those fields?
In SQL, it might look like this:
SELECT [Person].[FullName], SUM([Charge].[Total]) AS TotalAmount
FROM [Person] INNER JOIN [Charge] ON [Person].[PersonID] = [Charge].[PersonID]
WHERE [Charge].[ChargeType] = "Professional Fees"
AND [Charge].[ChargeDate] Between #01/01/2011# And #12/31/2011#
(The form allows the user to choose the type and date.)
When I call OpenReport, Access prompts the user to supply values for those fields not in the SELECT clause ([Charge].[ChargeType] and [Charge].[ChargeDate]), as if the fields were parameters.
The OpenReport call looks like this:
DoCmd.OpenReport "Summarized Charges by Salesperson", acViewPreview, strSelect
(where I dynamically generate the SQL you see above)
If I run the SQL directly in an Access query, I don't get the prompts (in case someone thought I might have misspelled the field names by accident).
I even tried revising the OpenReport call to this, splitting out the Where clause as a separate string, but I get the same result:
DoCmd.OpenReport "Summarized Charges by Salesperson", acViewPreview, strSelectWithoutWhere, strWhere
How can I define the report or SQL so that it won't prompt for those fields?