Collection of subreports in report (1 Viewer)

GaelicFatboy

Registered User.
Local time
Today, 07:43
Joined
Apr 17, 2007
Messages
100
Hi Chaps,

I'm trying to construct a collection of all the subreport names in a report, but I'm having trouble retrieving them.

CODE SO FAR:

Code:
Private Sub Report_Load()
Dim rptMain As Report_Xray_PackM1_rpt
Dim rptSub As Report

For Each rptSub In rptMain 
    Debug.Print rptSub.Name
Next

End Sub


The code goes through one iteration and halts on the "Next" statement.

Any thoughts?

Cheers

D
 
Last edited by a moderator:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 07:43
Joined
Jul 9, 2003
Messages
16,271
Wants to be more like this;-

Code:
Private Sub Report_Load()

Dim Ctrl As Control

    For Each Ctrl In Me.Controls
        If Ctrl.ControlType = acSubform Then
            MsgBox " >>> " & Ctrl.Name
        End If
    Next Ctrl

End Sub

Don't forget the code Tags!!!
 

GaelicFatboy

Registered User.
Local time
Today, 07:43
Joined
Apr 17, 2007
Messages
100
Thanks for the code, it works fine.

In the meantime, I had a little think over night and can up with this...

Code:
Dim rptMain As Object
Dim rptSub As Report

Set rptMain = Reports("Xray_PackM1_rpt")

bytY = rptMain.Count - 1

For bytX = 1 To bytY
    Debug.Print rptMain(bytX).Name
Next bytX

Your method is nearly half the length, guess I'm still learning.

Thanks for the help, it's very much appreciated. This forum is a God send.

Cheers

D
 
Last edited by a moderator:

Users who are viewing this thread

Top Bottom