Can't Pass Query name Tp Report Using Docmd 
Author Message
 Can't Pass Query name Tp Report Using Docmd

Has anyone noticed that you can't pass the name of a querydef to a report as
the third argument:

    DoCmd.OpenReport "Report1", acPreview,"qryCustomer"

In this example above the query "qryCustomer" does not become the
recordsource of the report.

To accomplish this you need to set the recordsource in the OnOpen event of
the report itself by placing the report name in a control on a form
soemwhere (or placing the name in a global variable I guess:

me.report.recordsource=forms!frmBlahBlah!ctrlBlahBlahBlah

where the query name is placed in control ctrlBlahBlahBlah.

The argument on the Openreport worked fine in A2.  Also I was unable to find
anything in the knowledgebase on this on MS Web Site.

Dick



Sun, 14 Jan 2001 03:00:00 GMT  
 Can't Pass Query name Tp Report Using Docmd
Syntax is different in 97 - it's not that it isn't working, it is not
intended to work as you suggest.  From Help:

Syntax:

DoCmd.OpenReport reportname[, view][, filtername][, wherecondition]

Keri Hardwick

Quote:

> Has anyone noticed that you can't pass the name of a querydef to a report as
> the third argument:

>     DoCmd.OpenReport "Report1", acPreview,"qryCustomer"

> In this example above the query "qryCustomer" does not become the
> recordsource of the report.

> To accomplish this you need to set the recordsource in the OnOpen event of
> the report itself by placing the report name in a control on a form
> soemwhere (or placing the name in a global variable I guess:

> me.report.recordsource=forms!frmBlahBlah!ctrlBlahBlahBlah

> where the query name is placed in control ctrlBlahBlahBlah.

> The argument on the Openreport worked fine in A2.  Also I was unable to find
> anything in the knowledgebase on this on MS Web Site.

>{*filter*}



Sun, 14 Jan 2001 03:00:00 GMT  
 Can't Pass Query name Tp Report Using Docmd

<<Syntax is different in 97 - it's not that it isn't working, it is not
intended to work as you suggest.  From Help:

Syntax:

DoCmd.OpenReport reportname[, view][, filtername][, wherecondition]

Sorry but that is exactly how it's intended to work - that's the syntax I am
.

Help says that filtername is :

"A string expression that's the valid name of a query in the current
database."

The example in Help is:

DoCmd.OpenReport "Sales Report", acViewNormal, "Report Filter"

which is identical to my

DoCmd.OpenReport "Report1", acPreview,"qryCustomer"

I'm sorry but it should be:

DoCmd.OpenReport "Report1", acViewPreview,"qryCustomer"

but the result is the same - it doesn't work.

If you want to test it make sure there is no predefined recordsource for the
report before trying this (in othere words REMOVE the recordsource before
saving it and you'll see that the bound controls come up with #Name? errors.

Thanx anyway.

Dick



Mon, 15 Jan 2001 03:00:00 GMT  
 Can't Pass Query name Tp Report Using Docmd
But it's a FILTER not a recordsource.  See how in the hHelp you are
quoting it says "filtername is", not "reocrdsource name is".  If your
report has no recordsource, there's nothing to filter; I don't need to
test it, I know it won't work.

If, in Access 2, using the syntax you described changed the
recordsource, the behavior has changed; in A97 it's just a filter -
i.e., same as setting report's filter property.

Keri

Quote:


> <<Syntax is different in 97 - it's not that it isn't working, it is not
> intended to work as you suggest.  From Help:

> Syntax:

> DoCmd.OpenReport reportname[, view][, filtername][, wherecondition]

> Sorry but that is exactly how it's intended to work - that's the syntax I am
> .

> Help says that filtername is :

> "A string expression that's the valid name of a query in the current
> database."

> The example in Help is:

> DoCmd.OpenReport "Sales Report", acViewNormal, "Report Filter"

> which is identical to my

> DoCmd.OpenReport "Report1", acPreview,"qryCustomer"

> I'm sorry but it should be:

> DoCmd.OpenReport "Report1", acViewPreview,"qryCustomer"

> but the result is the same - it doesn't work.

> If you want to test it make sure there is no predefined recordsource for the
> report before trying this (in othere words REMOVE the recordsource before
> saving it and you'll see that the bound controls come up with #Name? errors.

> Thanx anyway.

>{*filter*}



Fri, 19 Jan 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Passing two parameters tp a query in VBA

2. Passing a report object as an arguement to a form using prtdevmode and name

3. Passing Parameters to stored parameter queries using VB 5's Data Controls

4. 'Canned' data in VB program

5. Passing parameters to SQLServer using a Pass-Through query

6. Q: Pass a SQL query from VB to crystal report sub-report

7. variable tp pass a href - HOW?

8. Pass Null Value from VB6 tp Stored Proc in SQL 6

9. Crystal Reports Canned Code

10. sub-report (2 query's ) in crystal reports

11. Using Sub Query in Sql Query - Crystal Report 5.0

12. sub-report (2 query's ) in crystal reports

 

 
Powered by phpBB® Forum Software