Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2005
    Posts
    333

    Unanswered: Return to Calling Form

    I have a report that can be called from numerous forms. When the report is displayed I hide the calling form. I want to unhide the calling form when the report is closed. The problem is how do I know which form to make visible? I'm currently ussing a global variable that stores the name of the calling form as a string but I cannt figure out how to use this string to make the form visible. The following does not work.

    tempName = GLOBALNAME
    [forms]!tempName.visible = true

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    Quote Originally Posted by campster
    I'm currently ussing a global variable that stores the name of the calling form as a string but I cannt figure out how to use this string to make the form visible. The following does not work.

    tempName = GLOBALNAME
    [forms]!tempName.visible = true
    If you are storing the value as a string then you will refer to it like this:

    Forms(tempName).visible = True

    I've just set something up like this except I used the Tag property to store the value of the target form. When I open the form I input the name of the target form using, From.tag = frmName, I have an OK button with code to identify the Form to open.
    Code:
    Private Sub cmdHideMe_Click()
            Me.Visible = False
            Call ShowCallingForm
    End Sub
    
    Sub ShowCallingForm()
      Dim strFrmToOpen As String
      
      strFrmToOpen = Me.TAG
    
    DoCmd.OpenForm strFrmToOpen, acNormal, , , acFormEdit, acWindowNormal
    
    
    End Sub
    ~

    Bill

  3. #3
    Join Date
    Nov 2003
    Location
    LONDON
    Posts
    238
    Pass the name of the calling form to the report, then when the report closes unhide the form. You would use code along the lines of:

    ' To open the report from your form:
    DoCmd.OpenReport ReportName:="MyReportName",View:=acViewPreview,Ope nArgs:=Me.Name

    Then in the reports open event hide the form using:

    Forms(Me.OpenArgs).Visible = False

    and in the reports close event use:

    Forms(Me.OpenArgs).Visible = True

    Justin

  4. #4
    Join Date
    Feb 2004
    Posts
    533
    So thats what thats for,

    Good suggestion Justin, I've never used the Opening Arguments. Learned a new trick
    ~

    Bill

  5. #5
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441

    Slight warning - versions...

    Just be aware that openargs for reports became available in xp (2002). If you need this to work on previous versions use your current method, with the syntax demonstrated by savbill.
    Roy-Vidar

  6. #6
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    hmm - need new glasses, use the current method, with the syntax you demonstrated
    Roy-Vidar

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    recalling a hidden form

    Not sure about previous 2000 versions but usually when I hide a form after I call a report, in the report OnClose event I issue this.

    MyForm.setfocus
    docmd.restore
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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