Parameter Pop Up Form with Date Range

R

Robbie Doo

I have created a Pop Up form with Date Criteria. However, the Criteria is in
the RecordSource for each text box. Is there a way where the user can input
their own date range to retrieve information?

Thank you in advance.
 
R

Robbie Doo

Thank you Allen for a cool code. However, it doesn't work for charts. I get
the following Run-Time Error '2491'

The action or method is invalid because the form or report isn't bound to a
table or query
 
A

Allen Browne

Which approach did you use: method 1 or method 2?

If 2, which line generates this error?

Does the report have anything in its RecordSource property?
 
R

Robbie Doo

I used the method 2 and the line that generates the error is:

DoCmd.OpenReport strReport, acViewPreview, , strWhere

No, the Chart that is pulled from a query does not have any recordsource
except for when I click on the graph itself it gives me the rawsource where
the information comes from.
 
A

Allen Browne

Ah: the *report* has no recordsource.
The report contains a graph that has a RowSource.

Since the report itself is not bound to a query, you cannot apply a filter
to it. You will need to use Method 1: the parameter query.

If you want to tie that to a form where you enter the dates, create a form
with 2 unbound text boxes named txtStartDate and txtEndDate. Save the form
as (say) "ReportCriteria".

Now create the query to use as the RowSource for the graph.
In this query, include critera like this under the date field:
Between [Forms].[ReportCriteria].[txtStartDate] And
[Forms].[ReportCriteria].[txtEndDate]

Open the report in design view, and use this query as the RowSource for the
graph object.
 
R

Robbie Doo

Thank you Allen. It worked like a charm.

Allen Browne said:
Ah: the *report* has no recordsource.
The report contains a graph that has a RowSource.

Since the report itself is not bound to a query, you cannot apply a filter
to it. You will need to use Method 1: the parameter query.

If you want to tie that to a form where you enter the dates, create a form
with 2 unbound text boxes named txtStartDate and txtEndDate. Save the form
as (say) "ReportCriteria".

Now create the query to use as the RowSource for the graph.
In this query, include critera like this under the date field:
Between [Forms].[ReportCriteria].[txtStartDate] And
[Forms].[ReportCriteria].[txtEndDate]

Open the report in design view, and use this query as the RowSource for the
graph object.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Robbie Doo said:
I used the method 2 and the line that generates the error is:

DoCmd.OpenReport strReport, acViewPreview, , strWhere

No, the Chart that is pulled from a query does not have any recordsource
except for when I click on the graph itself it gives me the rawsource
where
the information comes from.
 

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

Top