Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-06-2017, 09:22 AM   #1
GaelicFatboy
Newly Registered User
 
Join Date: Apr 2007
Posts: 98
Thanks: 12
Thanked 0 Times in 0 Posts
GaelicFatboy is on a distinguished road
Collection of subreports in report

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 Uncle Gizmo; 12-06-2017 at 09:45 AM.
GaelicFatboy is offline   Reply With Quote
Old 12-06-2017, 09:44 AM   #2
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 8,962
Thanks: 295
Thanked 692 Times in 660 Posts
Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about Uncle Gizmo has a spectacular aura about
Send a message via Skype™ to Uncle Gizmo
Re: Collection of subreports in report

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!!!
__________________
Tony Hine - My Aspiration --- Finding a better way of Explaining ---
From this YouTube:-

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Uncle Gizmo is offline   Reply With Quote
The Following User Says Thank You to Uncle Gizmo For This Useful Post:
GaelicFatboy (12-07-2017)
Old 12-07-2017, 01:27 AM   #3
GaelicFatboy
Newly Registered User
 
Join Date: Apr 2007
Posts: 98
Thanks: 12
Thanked 0 Times in 0 Posts
GaelicFatboy is on a distinguished road
Re: Collection of subreports in report

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 Uncle Gizmo; 12-07-2017 at 01:58 AM. Reason: added code tags
GaelicFatboy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Main Report and Subreports luvphx09 Reports 8 01-28-2014 05:51 PM
Setting sub-report source object to a report in a collection rkmaitra Reports 10 04-08-2013 02:15 AM
Item not in collection when using field collection morphus Modules & VBA 4 01-14-2011 09:16 AM
2 Subreports in Main Report Jonathan Lueb Reports 4 05-07-2007 07:09 PM
Report with SubReports Erik Reports 4 02-03-2002 12:17 PM




All times are GMT -8. The time now is 11:00 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World