Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hide/unhide form (a2003)

    I'm trying to hide or minimize one form when moving to a second form and then hiding or minimizing that form when returning to the first. I've tried a number of different things:
    --Used the form property visible = False on the first form and then visible = True on the close button on the second form. If the form was not visible the cmdClose on the second form code couldn't find it.
    --Used the windows command to hide the first form and then unhide it in the cmdClose code on the second. It worked but it created the additional step of having to select which form to unhide in a separate window.
    --Used DoCmd.Minimize and DoCmd.Restore. While the first form was restored and the new record came up in the Find combo box as desired, but unless you moved the focus to another record, returned it to the Find combo box, and reselected the new record, you couldn't get the record display on the form.

    Surely there's a better way.

    I've attached the code in a txt file. You'll find the DoCmd.Minimize in the Select Case section of the VIEW FORM. You'll see the DoCmd.Restore command commented out in a couple of different places where I experimented with it on the ADD NEW RECORD FORM. The top location didn't work, the second yielded the results described above.

    Any ideas?

    E
    -------------------------------
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: hide/unhide form (a2003)

    Does my reply to <post#=360630>post 360630</post#> answer this one too?

  3. #3
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: hide/unhide form (a2003)

    Came across the following in on of my Access books, works beautifully:

    Because the second form can be opened from several different forms depending on how you design the navigational paths. For example, you may design the navigation so that the user can open the Orders form from the Main Switchboard, the Customer Orders form, or the Customers form. The second form needs to remember which form opened it so that it knows which form to unhide when you close it. The Tag proerty is ideal for this purpose. We'll create a pair of procedures that use the Tag property of the form you are opening to store the name of the form that opened it. We'll call the first form the "opener form" and the second form the "opened form."

    The OpenHide event function is assigned to the command button on the first form.

    Public Function OpenHide (strName As String)
    Dim strHide As String
    strHide = Screen.ActiveForm.Name
    Screen.ActiveFrom.Visible = False
    DoCmd.OpenForm strName
    Screen.ActiveForm.Tag = strHide
    End Function

    The strHide variable holds the name of the opener form using the Screen object to refer to it. After storing the name of the opener form in the strHide variable, the procedure hides the opener form. The procedure opens the second form and sets the Tag property of the opened form to the name of the opener form.

    When you close the second form by clicking a command button on it, you unhide the opener form using the CloseUnhide procedure.

    Public Function CloseHide (strName As String)
    Dim strHide As String
    If IsNull(Screen.ActiveForm.Tag) Then
    DoCmd.Close
    Else
    strHide = Screen.ActiveForm.Tag
    DoCmd.Close
    DoCmd.SelectObject acForm, strUnhide
    End If
    End Function

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: hide/unhide form (a2003)

    You should be able to do the same with the OpenArgs parameter of the OpenForm command.

Posting Permissions

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