HIDE / SHOW OF FORMS in MS Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kartikss
    New Member
    • Apr 2007
    • 25

    HIDE / SHOW OF FORMS in MS Access

    HI!!

    If I have 2 forms ie form 1 , form 2

    In Form 1 I have a command button to open form 2.

    how will i hide form 1 and show form 2, until i click on close button it open form 1 and form 2 should hide. in ms access

    how do i work on it on ms access?

    Thanks & bye

    Kartik
  • garethfx
    New Member
    • Apr 2007
    • 49

    #2
    Quick and cheap - Id use a simple macroso that the form 1 buttom runs the marco name (for instance) open_form2 where macro uses OpenForm (form2) -Close (object form1),


    Then reverse the process in form 2


    Gareth

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Originally posted by kartikss
      HI!!

      If I have 2 forms ie form 1 , form 2

      In Form 1 I have a command button to open form 2.

      how will i hide form 1 and show form 2, until i click on close button it open form 1 and form 2 should hide. in ms access

      how do i work on it on ms access?

      Thanks & bye

      Kartik
      'To Open Form2 and Hide Form1
      Code:
      Me.Visible = False
      DoCmd.OpenForm "Form2", acNormal, , , acFormEdit, acWindowNormal
      'To make Form1 visible again after Form2 is closed
      Code:
      Private Sub Form_Close()
        Forms![frmTest].Visible = True
      End Sub

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32661

        #4
        Essentially, if switching between forms as in the original request, the original code would open both forms and could also have a procedure which could be called from anywhere which switched between one being visible and the other.

        How this is triggered isn't specified so can be as flexible as you like but the code would be something like :
        Code:
        Public Sub SwitchForms()
            With Forms("Form 1")
                .Visible = Not .Visible
            End With
            With Forms("Form 2")
                .Visible = Not .Visible
            End With
        End Sub

        Comment

        Working...