Group:  Microsoft Access ยป microsoft.public.access.reports
Thread: Using parameters with queries and reports

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Using parameters with queries and reports
Michael 04.07.2006 21:38:01
Using parameters with queries and reports

I'm using a form to supply data to a parameter query. When I run the
report, it opens the form, I enter the data to pass to the query, click "ok"
it hides the form, runs the query and displays the resut in a datasheet query
view instead of the report. The report is never displayed.

Re: Using parameters with queries and reports
"Rick Brandt" <rickbrandt2[ at ]hotmail.com> 04.07.2006 21:47:17

"Michael" <Michael[ at ]discussions.microsoft.com> wrote in message
news:F925851E-CB9B-43AF-8481-4BCCC09D0967[ at ]microsoft.com...
[Quoted Text]
> Using parameters with queries and reports
>
> I'm using a form to supply data to a parameter query. When I run the
> report, it opens the form, I enter the data to pass to the query, click "ok"
> it hides the form, runs the query and displays the resut in a datasheet query
> view instead of the report. The report is never displayed.
>

If the report is bound to the query then there is no need to "run" the query.
Just remove that line of code and replace it with a line that opens the report.
Normally you would open such a form first and have it open the report rather
than having the report open the form. At that point it might be too late for
the report to make use of the parameter.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


Re: Using parameters with queries and reports
fredg <fgutkind[ at ]example.invalid> 04.07.2006 23:04:17
On Tue, 4 Jul 2006 14:38:01 -0700, Michael wrote:

[Quoted Text]
> Using parameters with queries and reports
>
> I'm using a form to supply data to a parameter query. When I run the
> report, it opens the form, I enter the data to pass to the query, click "ok"
> it hides the form, runs the query and displays the resut in a datasheet query
> view instead of the report. The report is never displayed.


The query is the record source for the report?
Here is an example that uses a Start date and End date as parameters
for the report record source (the query).

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'.

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

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.
When the report closes, it will close the form.
You never 'see' the query.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Re: Using parameters with queries and reports
Carol Shu 25.09.2006 15:36:01
I am creating a form to supply parameters to a report, so I enter code in the
report's OPEN & CLOSE events. I created a form (Sales by Category Dialog) and
a query (Source Query for Sales By Category Report).
the VBA code in the CLOSE & OPEN looks like this:

Private Sub Report_Close()
DoCmd.Close acForm, "Sales By Category Dialog"
End Sub

Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True

' Open Sales By Category Dialog
DoCmd.OpenForm "Sales By Category Dialog", , , , , acDialog

' Cancel Report if User Clicked the Cancel Button
If IsLoaded("Sales By Category Dialog") = False Then Cancel = True

' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub

Computer says : compile error: sub or function not defined, ("IsLoaded"
marked yellow), any idea why?

"fredg" wrote:

[Quoted Text]
> On Tue, 4 Jul 2006 14:38:01 -0700, Michael wrote:
>
> > Using parameters with queries and reports
> >
> > I'm using a form to supply data to a parameter query. When I run the
> > report, it opens the form, I enter the data to pass to the query, click "ok"
> > it hides the form, runs the query and displays the resut in a datasheet query
> > view instead of the report. The report is never displayed.
>
>
> The query is the record source for the report?
> Here is an example that uses a Start date and End date as parameters
> for the report record source (the query).
>
> 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'.
>
> As criteria in the query date field write:
> Between forms!Paramform!StartDate and forms!ParamForm!EndDate
>
> 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.
> When the report closes, it will close the form.
> You never 'see' the query.
> --
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net