Solved

Set report name from an open form

Posted on 2011-02-22
2
407 Views
Last Modified: 2013-11-27
Please see "What I want" below

Private Sub Report_Click()

    '                     >>>>>>>>>>>><<<<<<<<<<<<<<
   
    Dim stDocName As String
    Dim ctl As Control
    Dim rpt As Report
   

    stDocName = Forms![frmResize_Report]![InReport]    'InReport is a control on an open form.

    DoCmd.OpenReport stDocName, acDesign  'Opens report in design view.
   
   
    Set rpt = Reports!rptProfiles1
'What I want is to set rpt like
      'Set rpt = Forms![frmResize_Report]![InReport]
' i.e. read the value to which to set rpt from Forms![frmResize_Report]![InReport], because I want to change the code for each new report. Will it make it easier if I mede it into a function?


       
    '              >>>>>>>>>>Addressing Sections>>>>>>>>>>>
   
    On Error GoTo endofsections

    For i = 0 To 100
        Debug.Print rpt.Section(i).Name, rpt.Section(i).[Height]
    Next i

endofsections:
    ' exit on error because you can't tell in advance how many sections there are
    Exit Sub
   
End Sub
0
Comment
Question by:Fritz Paul
2 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 34950951
If you mean you wish to set your rpt Object to the report you opened:

Set rpt = Reports(stDocName)


0
 

Author Closing Comment

by:Fritz Paul
ID: 34951057
Fabulous!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now