How do I link a chart and text box within a report to a query?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a query that finds certain records between two dates. I then used
this query as a base for report that has a graph and text boxes to act as
lists. But now when I open up the report it was asked for the start and end
twice because the graph goes to query and then the text box refers to the
query. How can I solve this problem. Can I link the text box and graph
somehow or write a macro?

Thanks
 
I have a query that finds certain records between two dates. I then used
this query as a base for report that has a graph and text boxes to act as
lists. But now when I open up the report it was asked for the start and end
twice because the graph goes to query and then the text box refers to the
query. How can I solve this problem. Can I link the text box and graph
somehow or write a macro?

Thanks

Use a Form to enter the parameters.

Create an unbound form.
Add 2 unbound text controls.
Set their format to a valid date format.
Name them "StartDate" and "EndDate"

Add a Command Button to the form.
Code the button's click event:

Me.Visible = False

Name this form 'ParamForm'.

In the Report's Record Source [CompanyID] field criteria line write:
forms!ParamForm!FindCompany

As criteria in the query date field write:
Between forms!Paramform!StartDate and forms!ParamForm!EndDate

Use the same criteria in the Graph record source.

Next, code the report's Open event:
DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the report's Close event:
DoCmd.Close acForm, "ParamForm"

When ready to run the report, open the report.
The form will open and wait for the selection of the Company and the
entry of the starting and ending dates wanted.
Click the command button and then report will run.
The graph will use the same criteria.
When the report closes, it will close the form.
 
Fredg:

I have found your advice very helpful.

However, I have hit one snag. When I try to display the StartDate and
EndDate entries in a chartreport header it ignores my like a stop sign (but
it work in a normal report).

Any suggestion?

Cowboy

fredg said:
I have a query that finds certain records between two dates. I then used
this query as a base for report that has a graph and text boxes to act as
lists. But now when I open up the report it was asked for the start and end
twice because the graph goes to query and then the text box refers to the
query. How can I solve this problem. Can I link the text box and graph
somehow or write a macro?

Thanks

Use a Form to enter the parameters.

Create an unbound form.
Add 2 unbound text controls.
Set their format to a valid date format.
Name them "StartDate" and "EndDate"

Add a Command Button to the form.
Code the button's click event:

Me.Visible = False

Name this form 'ParamForm'.

In the Report's Record Source [CompanyID] field criteria line write:
forms!ParamForm!FindCompany

As criteria in the query date field write:
Between forms!Paramform!StartDate and forms!ParamForm!EndDate

Use the same criteria in the Graph record source.

Next, code the report's Open event:
DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the report's Close event:
DoCmd.Close acForm, "ParamForm"

When ready to run the report, open the report.
The form will open and wait for the selection of the Company and the
entry of the starting and ending dates wanted.
Click the command button and then report will run.
The graph will use the same criteria.
When the report closes, it will close the form.
 
Back
Top