Parameters to OpenReport

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

Guest

I know it is possible to filter the reports by sending in a criteria to the
OpenReport command.
But in this case I have a complex "piled" query: Query3 built on Query2
built on Query1, and I need to set the criteria on Query1!
Usually I solve this by pointing to a control expression in the Query:
Forms!frmThis!ctrlThat

This time it is more complicated: The piled query is used in many other
places as well, where I need to manipulate the resulting recordset. Neither
the DAO nor the ADO recordsets will evaluate the control expression even if
the required form is open. I solved this by specifying the criteria as a
typed parameter and adding it to the ADO command. This works fine. The
recordset is OK.

Now the problem is how to add the parameter value to the query when opening
the report .... Any ideas?
 
Hello,

You could change the OpenReport line of code in the command button's event
procedure to use its WhereCondition argument.

For example, if the claim number field in the table is a numeric type:
DoCmd.OpenReport stDoc, , , "claimnum= " & thetextbox

Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================


This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
 
As I said: "I know it is possible to filter the reports by sending in a
criteria to the
OpenReport command" ....
But that doesn't work in this case. The resulting query doesn't have the
parameter as a column. I have this "piled" query with a specified parameter
in the first query in the line.
Maybe I am not making myself clear with that parameter. In the design of
Query1 I added [ChosenYear] as criteria, and in the menu "Query - Parameters"
I specified a datatype of integer for the paramater.

ADO Command object can detect the parameter of the subquery and set its
value by using a Command Parameter, but I find no similar way of specifying
the parameter in the report design

So the question is: Can I specify a value of a named parameter belonging to
a subquery, when opening a report?

Maybe a workaround is to load the report by sending in an open recordset
instead of specifying a Select string? I never did that, because it looked
unconvenient to design the report without having the underlying recordset to
connect the controls. But I guess it is possible in some way?
 
Hello,

Sorry I did not catch this in the first place. Based on my research, I did
not find a method to feed the parameters of subquery when openning the
report based on a parent query.

I agree with you that use RS you want might be a workaround. Please refer
to the following article for related information:

http://www.mvps.org/access/reports/rpt0014.htm

Also, I tried the following code to set paramter query but report still
prompts parameter

Dim db As Database
Dim qry As QueryDef
Const strQueryName = "paramquery"
Set db = CurrentDb()
Set qry = db.QueryDefs(strQueryName)
qry.Parameters("Number") = 1

Regards,

Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================


This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
Thread-Topic: Parameters to OpenReport
thread-index: AcYyCctm30v1D2dwQgaIAci9fCH7IA==
X-WBNR-Posting-Host: 192.138.116.230
From: "=?Utf-8?B?SmFrb2IgTGl0aG5lcg==?=" <[email protected]>
References: <[email protected]>
Subject: RE: Parameters to OpenReport
Date: Wed, 15 Feb 2006 00:28:27 -0800
Lines: 22
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.access.queries
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.access.queries:268601
X-Tomcat-NG: microsoft.public.access.queries

As I said: "I know it is possible to filter the reports by sending in a
criteria to the
OpenReport command" ....
But that doesn't work in this case. The resulting query doesn't have the
parameter as a column. I have this "piled" query with a specified parameter
in the first query in the line.
Maybe I am not making myself clear with that parameter. In the design of
Query1 I added [ChosenYear] as criteria, and in the menu "Query - Parameters"
I specified a datatype of integer for the paramater.

ADO Command object can detect the parameter of the subquery and set its
value by using a Command Parameter, but I find no similar way of specifying
the parameter in the report design

So the question is: Can I specify a value of a named parameter belonging to
a subquery, when opening a report?

Maybe a workaround is to load the report by sending in an open recordset
instead of specifying a Select string? I never did that, because it looked
unconvenient to design the report without having the underlying recordset to
connect the controls. But I guess it is possible in some way?
 
Back
Top