Which form opened this report?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cyberdwarf
    Recognized Expert New Member
    • Nov 2006
    • 218

    #1

    Which form opened this report?

    Hi,

    Being very dumb today!

    I need to know, in VBA code, which form was used to call a report (using DoCmd.OpenRepor t)

    Must be some sort of method or property to do this???

    TIA

    Steve
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by cyberdwarf
    Hi,

    Being very dumb today!

    I need to know, in VBA code, which form was used to call a report (using DoCmd.OpenRepor t)

    Must be some sort of method or property to do this???

    TIA

    Steve
    Use the OpenArgs Property of the OpenReport Method as in:
    Code:
    Dim stDocName As String
    
    stDocName = "rptEmployee"
    DoCmd.OpenReport stDocName, acPreview, , , acWindowNormal, "My Form Name"
    Then, in the Report's Open() Event, place code similiar to this. This should point you in the right direction.
    Code:
    Private Sub Report_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
      MsgBox "Form " & Me.OpenArgs & " opened this Report"
    End If
    End Sub

    Comment

    • cyberdwarf
      Recognized Expert New Member
      • Nov 2006
      • 218

      #3
      Hi, ADezii


      Thx for your response.

      Unfortunately, the OpenArgs property is already in use for other purposes ;-(

      Ho hum

      Steve

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by cyberdwarf
        Hi, ADezii


        Thx for your response.

        Unfortunately, the OpenArgs property is already in use for other purposes ;-(

        Ho hum

        Steve
        How about assigning a Public Variable representing the Form's Name when it is opened. It can then be read anywhere within the Project?

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          I don't think there is a prescribed way to do this I'm afraid Cyber.
          ADezii's idea is probably the best you'll get.

          Comment

          Working...