Changing caption property with code w/o opening report

MikeAngelastro

Registered User.
Local time
Yesterday, 23:43
Joined
Mar 3, 2000
Messages
254
Hi,

I need to be able to run a report multiple times. However, I need to have a different caption each time I run it. How do you change the caption property of a report with code without opening it.

The helper suggests that a report is in the documents collection until it is opened, at which time it becomes a member of the reports collection. It's all very very confusing when all I want to do is change the value of a property. The code below does not work:

REPORTS![rptReportName].Cation = "Something"

unless the report is running. It's seems more complicated them I think it should be.

Any help?

Mike
 
You can change captions in the OnOpen event, as in:
Me!YourLabelName.Caption = "Your Caption"

Since you say you have a need to change the caption, instead of a fixed string you can use a string variable that is set outside of the report. Then the code becomes:

Me!YourLabelName.Caption = YourVariable
 
Does anybody know how to change the caption of a report via VBA? Not a control on a report but the report itself. I am pretty sure that you can't do it without opening the report but I can't figure out how to do it?

I've tried (using method here. It's for ACC 97 and I am using ACC 2000. Did it change any between the two versions?)

Code:
ReportName = "Report"
Dim myReport as Report
Set myReport = Report(ReportName)

myReport.Caption = "MyCaption"
Doesn't work. I keep getting Compile error: Expected variable or procedure, not Project.

Tried
Code:
Reports(rptname).Caption = "MyCaption"
Reports.[rptname].Caption = "MyCaption"
Reports!rptname.Caption = "MyCaption"

I can get the caption doing this
Code:
myCaption = Eval("Reports(" & rptname & ").Caption")
but not
Code:
myCaption = Reports(rptname).Caption

This is driving me nuts!
Is this impossible to do?!
 
Last edited:
Code:
me.clue = 0
MY problem was the the Project Name (based on the name I gave the database file) is Reports (Reports.mdb) so it gave me a complile error. I have to rename the File and the Project Name uner the VB Window to something else!

That'll teach me to name my file something like that!
 
MikeAngelastro said:
How do you change the caption property of a report with code without opening it.

The code below does not work:

REPORTS![rptReportName].Cation = "Something"

unless the report is running. It's seems more complicated them I think it should be.

Any help?

Mike
See sample database.
:)
 

Users who are viewing this thread

Back
Top Bottom