Making changes to multiple reports.

  • Thread starter Thread starter Daniel Lalonde
  • Start date Start date
D

Daniel Lalonde

Hello,

Any suggestions are appreciated. I need to make a small
change to a large number of similar reports and am
wondering if there is a simple programming solution rather
than adjusting each one manually. Each report has one
label and two text boxes which need their .Visible
properties set to true.

The objects are:
lblAcute
txtAcute
txtPercentOfTotalAcute

I would like to create a function that would open each
report and make the changes. How would I cycle through
the db, open each report, and then set the respective
properties to true? Should I use a macro instead?

Thanks again,

Daniel
 
Daniel said:
Any suggestions are appreciated. I need to make a small
change to a large number of similar reports and am
wondering if there is a simple programming solution rather
than adjusting each one manually. Each report has one
label and two text boxes which need their .Visible
properties set to true.

The objects are:
lblAcute
txtAcute
txtPercentOfTotalAcute

I would like to create a function that would open each
report and make the changes. How would I cycle through
the db, open each report, and then set the respective
properties to true? Should I use a macro instead?

Forget using macros! ;-)

This is a one time change, right? You do not want to do
this kind of thing at run time.

Create a Public Sub procedure in a standard module so it can
be called from the debug window. It should look like this
pretty crude air code:

Public Sub FixReports()
Dim db As Database
Dim doc As Document

Set db = CurrentDb()
On Error Resume Next
For Each doc In db.Containers("Reports").Documents
DoCmd.OpenReport doc.Name, acViewDesign
With Reports(doc.Name)
.lblAcute.Visible = True
.txtAcute.Visible = True
.txtPercentOfTotalAcute.Visible = True
End With
DoCmd.Close acReport, doc.Name, acSaveYes
Next doc

Set db = Nothing

You really should add proper error handling to catch any
real errors that might occur and to keep track if no change
is made to the report so you can avoid saving an unchanged
report.
 
Back
Top