VBA Code to change a Lable on Report

D

Dennis

Access 2003

The following code works fine to access the report Caption and Record Source.

Dim myReportName As String
myReportName = "October 2003"
DoCmd.CopyObject "", myReportName, acReport, "myUpdateReport"
DoCmd.OpenReport myReportName, acViewDesign
With Reports(myReportName)
.Caption = "Solon Utilities" & myReportName
.RecordSource = "qry" & myReportName
End With
DoCmd.Save , myReportName
DoCmd.Close acReport, myReportName


What Object, Method, Property is appropriate to change the contents of Label24 in MyReportName
from "XYZ" to "ABC"?



TIA Dennis
 
A

Allen Browne

Try:
Me.Label24.Caption = "ABC"
but there may be a timing issue here. You need to set the Caption of the
label before its section is printed.
 
D

Dennis

Allen,

Thank you!

I was able to get Label24.Caption = "XYZ" to work.
in the following Code:

(..... Dim & "set" my ReportName)

With Reports(myReportName)
.Caption = "Utilities" & myReportName
.RecordSource = myReportName
.Label24.Caption = "Utilities " & myReportName
End With

That said, I am extremely interested in the use of "Me." I have seen it referenced quite often.

What is its significance?

Where would it be used and Why?

Thanks

Dennis
 
A

Allen Browne

"Me" is a reference to the instance of the form/report/class module that you
are using.

If your code is in the module of the report, you can use:
With Me
instead of:
With Reports(myReportName)

If your code is in a standard module, stay with the syntax you have.
 

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