+ Reply to Thread
Results 1 to 5 of 5

userforms showing and hiding

  1. #1
    Registered User
    Join Date
    08-31-2005
    Posts
    13

    userforms showing and hiding

    I have two userforms in my program. I set it up so that clicking on a command button on userform1 hides userform1 and shows userform2. Userform2 is set up in the same way such that clicking on a commandbutton will hide userform2 and show userform1.

    the problem is that the userforms are not the same size. Userform2 is wide and short while userform1 is tall and skinny. And when I hide a userform and show the other userform (via the command buttons) you can still see the hidden userform behind the userform being shown. In other words the userforms are not really being hidden. I've set application.screenupdating to true thinking that might be the problem but it isn't.

    Here is the code in userform1:

    Please Login or Register  to view this content.
    And the code in userform2:

    Please Login or Register  to view this content.

  2. #2
    Charlie
    Guest

    RE: userforms showing and hiding

    It worked ok for me, but I don't have any other controls or code to consider.
    Are you updating a control on one of the forms or doing something that may
    be keeping the form active? Try putting "DoEvents" in the button click
    events.

    Private Sub CommandButton2_Click()
    UserForm1.Hide
    UserForm2.Show
    DoEvents
    End Sub

    "Laurin" wrote:

    >
    > I have two userforms in my program. I set it up so that clicking on a
    > command button on userform1 hides userform1 and shows userform2.
    > Userform2 is set up in the same way such that clicking on a
    > commandbutton will hide userform2 and show userform1.
    >
    > the problem is that the userforms are not the same size. Userform2 is
    > wide and short while userform1 is tall and skinny. And when I hide a
    > userform and show the other userform (via the command buttons) you can
    > still see the hidden userform behind the userform being shown. In
    > other words the userforms are not really being hidden. I've set
    > application.screenupdating to true thinking that might be the problem
    > but it isn't.
    >
    > Here is the code in userform1:
    >
    >
    > Code:
    > --------------------
    > Private Sub CommandButton2_Click()
    > UserForm1.Hide
    > UserForm2.Show
    > End Sub
    > --------------------
    >
    > And the code in userform2:
    >
    >
    > Code:
    > --------------------
    > Private Sub CommandButton2_Click()
    > UserForm2.Hide
    > UserForm1.Show
    > End Sub
    > --------------------
    >
    >
    > --
    > Laurin
    > ------------------------------------------------------------------------
    > Laurin's Profile: http://www.excelforum.com/member.php...o&userid=26832
    > View this thread: http://www.excelforum.com/showthread...hreadid=494931
    >
    >


  3. #3
    Registered User
    Join Date
    08-31-2005
    Posts
    13
    "DoEvents" worked perfectly. Thank you.

  4. #4
    Registered User
    Join Date
    12-20-2005
    Posts
    5
    Quote Originally Posted by Laurin
    Here is the code in userform1:
    Please Login or Register  to view this content.
    And the code in userform2:
    Please Login or Register  to view this content.
    I don't see what you could be doing wrong... I tried with the exact same code, and it works. Afterwards, I tried this:
    Here is the code in userform1:
    Please Login or Register  to view this content.
    And the code in userform2:
    Please Login or Register  to view this content.
    which also worked.
    Maybe it's because you set the screenupdating to True at the wrong moment? Test it by commenting out the lines that say 'Screenupdating = False'.


    Edit: ok, seems it's already solved...
    Last edited by Excelibur; 12-20-2005 at 01:58 PM. Reason: I was too late :)

  5. #5
    Tom Ogilvy
    Guest

    Re: userforms showing and hiding

    Private Sub CommandButton2_Click()
    UserForm1.Hide
    UserForm2.Show
    Application.ScreenUpdating = False
    Application.ScreenUpdating = True
    End Sub

    Private Sub CommandButton2_Click()
    UserForm2.Hide
    UserForm1.Show
    Application.ScreenUpdating = False
    Application.ScreenUpdating = True
    End Sub

    --
    Regards,
    Tom Ogilvy

    "Laurin" <[email protected]> wrote in
    message news:[email protected]...
    >
    > I have two userforms in my program. I set it up so that clicking on a
    > command button on userform1 hides userform1 and shows userform2.
    > Userform2 is set up in the same way such that clicking on a
    > commandbutton will hide userform2 and show userform1.
    >
    > the problem is that the userforms are not the same size. Userform2 is
    > wide and short while userform1 is tall and skinny. And when I hide a
    > userform and show the other userform (via the command buttons) you can
    > still see the hidden userform behind the userform being shown. In
    > other words the userforms are not really being hidden. I've set
    > application.screenupdating to true thinking that might be the problem
    > but it isn't.
    >
    > Here is the code in userform1:
    >
    >
    > Code:
    > --------------------
    > Private Sub CommandButton2_Click()
    > UserForm1.Hide
    > UserForm2.Show
    > End Sub
    > --------------------
    >
    > And the code in userform2:
    >
    >
    > Code:
    > --------------------
    > Private Sub CommandButton2_Click()
    > UserForm2.Hide
    > UserForm1.Show
    > End Sub
    > --------------------
    >
    >
    > --
    > Laurin
    > ------------------------------------------------------------------------
    > Laurin's Profile:

    http://www.excelforum.com/member.php...o&userid=26832
    > View this thread: http://www.excelforum.com/showthread...hreadid=494931
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1