Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jun 2002
    Nottingham, Nottinghamshire, United Kingdom
    Thanked 0 Times in 0 Posts

    Passing information to a report (All)

    I want to design a report that can be opened from several different forms using DoCmd.OpenReport. At present I have several virtually identical reports but could simplify these down to one if I was able to interrogate the calling forms through the Report's activate event.


    If CallingForm = frmThis Then
    Change the contents of certain text boxes

    My problem is I can't work out how to reference the name of the calling form. Me.Name gives the name of the report not the form that called it, Me.Parent.Name gives an error. Can anyone help me with the syntax.

    Many thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Passing information to a report (All)

    In Access 2002 and up, reports have a new OpenArgs property that you can set in DoCmd.OpenReport; you can use this to pass the name of the calling form. OpenArgs is not available in Access 2000 and earlier, however.

    You can define a global variable in a standard module:

    Public gstrCallingForm As String

    In the code that opens the report, set this variable to the name of the form:

    gstrCallingForm = Me.Name
    DoCmd.OpenReport "rptMyReport", acViewPreview

    And in the code behind the report:

    Select Case gstrCallingForm
    Case "frmThis"
    Case "frmThat"
    Case Else
    End Select
    ' Reset variable for next time
    gstrCallingForm = ""

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts