Syntax to Pass Variables

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Set objRpt = .Reports!['" & strReportName & "']"

Notice single quotes - If that doesn't work try

Set objRpt = .Reports![" & strReportName & "]"
 
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
 
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
 
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
 
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
 
Back
Top