Solved

Set report name from an open form

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

707 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

9 Experts available now in Live!

Get 1:1 Help Now