Solved

Set report name from an open form

Posted on 2011-02-22
2
408 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

Suggested Solutions

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

831 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