Syntax to Pass Variables

G

Guest

I want to pass a variable with a report name instead of specific report name
but can't seem to get it to work.

This Works:
Set objRpt = .Reports![DB1_rpt3_control_totals]

How can I replace "DB!_rpt3_control_totals" with a variable, "strReportName"?

This Does not work:
Set objRpt = .Reports![& """ strReportName """ &]

What is the correct syntax?

Note: I am trying to evaluate the "Pages" of a report that is open and in
preview mode. The report is in an external database, not the current
database.

Thank You

Ross
 
G

Guest

Set objRpt = .Reports!['" & strReportName & "']"

Notice single quotes - If that doesn't work try

Set objRpt = .Reports![" & strReportName & "]"
 
G

Guest

Klatuu,

No Luck.

Thank you.

Klatuu said:
Set objRpt = .Reports!['" & strReportName & "']"

Notice single quotes - If that doesn't work try

Set objRpt = .Reports![" & strReportName & "]"

Ross said:
I want to pass a variable with a report name instead of specific report name
but can't seem to get it to work.

This Works:
Set objRpt = .Reports![DB1_rpt3_control_totals]

How can I replace "DB!_rpt3_control_totals" with a variable, "strReportName"?

This Does not work:
Set objRpt = .Reports![& """ strReportName """ &]

What is the correct syntax?

Note: I am trying to evaluate the "Pages" of a report that is open and in
preview mode. The report is in an external database, not the current
database.

Thank You

Ross
 
K

Ken Snell [MVP]

Try this, assuming
(1) that the . in front of Reports is because you have a "With
DatabaseObjectName" prior to it
(2) that strReportName is the name of the report

Set objRpt = .Reports(strReportName)

--

Ken Snell
<MS ACCESS MVP>


Ross said:
Klatuu,

No Luck.

Thank you.

Klatuu said:
Set objRpt = .Reports!['" & strReportName & "']"

Notice single quotes - If that doesn't work try

Set objRpt = .Reports![" & strReportName & "]"

Ross said:
I want to pass a variable with a report name instead of specific report
name
but can't seem to get it to work.

This Works:
Set objRpt = .Reports![DB1_rpt3_control_totals]

How can I replace "DB!_rpt3_control_totals" with a variable,
"strReportName"?

This Does not work:
Set objRpt = .Reports![& """ strReportName """ &]

What is the correct syntax?

Note: I am trying to evaluate the "Pages" of a report that is open and
in
preview mode. The report is in an external database, not the current
database.

Thank You

Ross
 
G

Guest

Ken


It Works!

I have learned that it is only simple when you KNOW the answer.

Thank you so much!

Ross



Ken Snell said:
Try this, assuming
(1) that the . in front of Reports is because you have a "With
DatabaseObjectName" prior to it
(2) that strReportName is the name of the report

Set objRpt = .Reports(strReportName)

--

Ken Snell
<MS ACCESS MVP>


Ross said:
Klatuu,

No Luck.

Thank you.

Klatuu said:
Set objRpt = .Reports!['" & strReportName & "']"

Notice single quotes - If that doesn't work try

Set objRpt = .Reports![" & strReportName & "]"

:

I want to pass a variable with a report name instead of specific report
name
but can't seem to get it to work.

This Works:
Set objRpt = .Reports![DB1_rpt3_control_totals]

How can I replace "DB!_rpt3_control_totals" with a variable,
"strReportName"?

This Does not work:
Set objRpt = .Reports![& """ strReportName """ &]

What is the correct syntax?

Note: I am trying to evaluate the "Pages" of a report that is open and
in
preview mode. The report is in an external database, not the current
database.

Thank You

Ross
 
K

Ken Snell [MVP]

You're welcome.
--

Ken Snell
<MS ACCESS MVP>

Ross said:
Ken


It Works!

I have learned that it is only simple when you KNOW the answer.

Thank you so much!

Ross
 

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