report based query

G

Guest

Thanks for taking the time to read the following:

I have a query and report based on that query which requires 2 parameters to
be filled, a start date and an end date. To confuse matters, I have a pie
chart as a subreport based on the same query and parameters.
My problem arises when the user opens the report they would have to enter
the range date parameters 5 times. Is there a way to open the report with
entering the parameter only once?
 
F

fredg

Thanks for taking the time to read the following:

I have a query and report based on that query which requires 2 parameters to
be filled, a start date and an end date. To confuse matters, I have a pie
chart as a subreport based on the same query and parameters.
My problem arises when the user opens the report they would have to enter
the range date parameters 5 times. Is there a way to open the report with
entering the parameter only once?

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 (the query) as criteria in the date
field write:

Between forms!Paramform!StartDate and forms!ParamForm!EndDate

(Use the same criteria in the chart's query.)

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 entry of the starting and ending
dates wanted.
Click the command button and then report will run.
Because the chart uses the same parameters it will not ask for them
again.
When the report closes, it will close the form.
 
G

Guest

Thanks for replying.
I am a new user, unexperienced. What do you mean by unbound form?
 
G

Guest

thanks for taking the time to reply.
I am a new and unexperienced user of Access, what do you mean by Create an
unbound form.?
 
G

Guest

How would you perform the following operation?
Add a Command Button to the form.
Code the button's click event:

Me.Visible = False
 
G

Guest

After performing the operation you stated, I get the following message:
"The record source 'Between form!Paramform!BeginningDate and
forms!Paramform!EndingDate' specified on this form or report does not exist."
What does this mean? Please help.
 
F

fredg

Thanks for replying.
I am a new user, unexperienced. What do you mean by unbound form?

On the main database folder, select Forms.
Then click on New.
When the New Form dialog opens select Design View.
Do NOT enter anything in the Table/query drop down box.

When the design view of the form opens, click on the Toolbox button.
If the Tool wizard button (the wand with some stars) is down, click on
it (to raise it).
Then click on and drag the text control button (Ab) onto the form.
Repeat for the second text control.

Display each controls property sheet.
Set the Format Property of each to Short Date.
Name one "StartDate", the other "EndDate" (without the quotes).

From the toolbox, select and drag the command button onto your form.
In the ToolBox, click on the wizard again to depress it.

Now show the command button property sheet.
Click on the Event tab.
On the Click line, write:
[Event Procedure]
Click on the little button with the 3 dots that appears on that line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines, write:

Me.Visible = False

Save the changes by closing the window.
Name the form "ParamForm" (without the quotes).

Save the form.

Now open the query.
On the DateField criteria line, write:
Between forms!ParamForm!StartDate and forms!ParamForm!EndDate

Save the query.
Repeat on any other query used in the report, sub-report, chart, etc.

Then open the report in design view.
Show the report's property sheet.
On the Open line, write:
[Event Procedure]
Click on the button with the 3 dots on that line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines, write:

DoCmd.OpenForm "ParamForm", , , , , acDialog
Close the code window.
Then do the same thig in the report's close event, writing:
DoCmd.Close acForm, "ParamForm"

Save the changes and that should be all you need do.
 
F

fredg

After performing the operation you stated, I get the following message:
"The record source 'Between form!Paramform!BeginningDate and
forms!Paramform!EndingDate' specified on this form or report does not exist."
What does this mean? Please help.

You evidently wrote
"Between form!Paramform!BeginningDate and
forms!Paramform!EndingDate" in the wrong place.

See my reply to one of your other messages in this thread.
 

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