Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Set report name from an open form

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained 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…

791 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