Report / SubReport Question

  • Thread starter Thread starter Andre Laplume via AccessMonster.com
  • Start date Start date
A

Andre Laplume via AccessMonster.com

I inhereted a db that has a number of reports. Each report has several
subreports. Many of the reports are no longer run. I can easily delete them
but I am finding 'lonesome' subreports that are no longer needed. Is there a
way to get a list of all the reports, that act as subreports which no longer
connect to anything...hope this makes sense!
 
You would need to run a code routine that would open each report in the
AllReports Collection in design mode. Once you have the report open, loop
through all controls on the report. If the ControlType is acSubform then get
the SourceObject property of that control. Do a Debug.Print of the report's
name and the SourceObject. This will tell you which subreport is being used
by that report.

Example:
Public Sub FindSubReports()
Dim rpt As AccessObject, db As Object, ctl As Control
Set db = Application.CurrentProject
For Each rpt In db.AllReports
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
For Each ctl In Reports(rpt.Name).Controls
If ctl.ControlType = acSubform Then
Debug.Print rpt.Name & Space(5) & ctl.SourceObject
End If
Next
DoCmd.Close acReport, rpt.Name, acSaveNo
Next
Set db = Nothing
End Sub
 
THANKS!

Wayne said:
You would need to run a code routine that would open each report in the
AllReports Collection in design mode. Once you have the report open, loop
through all controls on the report. If the ControlType is acSubform then get
the SourceObject property of that control. Do a Debug.Print of the report's
name and the SourceObject. This will tell you which subreport is being used
by that report.

Example:
Public Sub FindSubReports()
Dim rpt As AccessObject, db As Object, ctl As Control
Set db = Application.CurrentProject
For Each rpt In db.AllReports
DoCmd.OpenReport rpt.Name, acViewDesign, , , acHidden
For Each ctl In Reports(rpt.Name).Controls
If ctl.ControlType = acSubform Then
Debug.Print rpt.Name & Space(5) & ctl.SourceObject
End If
Next
DoCmd.Close acReport, rpt.Name, acSaveNo
Next
Set db = Nothing
End Sub
I inhereted a db that has a number of reports. Each report has several
subreports. Many of the reports are no longer run. I can easily delete
[quoted text clipped - 4 lines]
longer
connect to anything...hope this makes sense!

--
OOPs a typo...the statement that DOES NOT work is:

AdjAmt: Sum(IIf([TYPE]=2 And Left(Date(),2)="07",[Amt]*[Percent],IIf([TYPE]=1,
[Amt]*[Percent],0)))


Message posted via AccessMonster.com
 
Back
Top