Consulting

Results 1 to 5 of 5

Thread: Sleeper: Switch Form

  1. #1
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location

    Exclamation Sleeper: Switch Form

    hi all,

    I'm facing lots of errors when closing main form and show other form..

    I have 4 form

    UserForm1, UserForm2, UserForm3, UserForm4
    All other 3 forms is linked to UserForm1.

    1. But after I show and closed UserForm2 a few time, it cannot close by the upright buttons after showing it the second time.
    2. when I closed one of the other 3 form, userform1 should appear..
    3. but when i show again the other 3 form, every data in the form's textbox was gone...

    Also may I know how to terminate a form completely out of memory?
    And call them again with a fresh copy thorugh userform1?

    Please help....

    File attached....

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    To terminate a form completely, you Unload it (Unload UserForm1 or Unload Me). This may be your problem since you are unloading Userform1. Do not unload UserForm1 if you want it to be there when you close the other userforms.

    Also you cannot hide the userform when it is being closed. You can do something like this though.



    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = 0 Then
            Cancel = True
            Me.Hide
        End If
    End Sub

  3. #3
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    Thx, Jake.

    But I'm still facing errors....
    Error msg below...
    The second time that I opened UserForm2, it cannot be closed...
    Please help...

    Where does CloseMode and Cancel takes value from?

    Thx

  4. #4
    VBAX Mentor Justinlabenne's Avatar
    Joined
    Jul 2004
    Location
    Clyde, Ohio
    Posts
    408
    Location
    If it's not outside your projects scope, maybe setting the form's modal property to "False" can help to alleviate some of your pain. Just put "False" behind all like:

    Userform#.Show False

    Plus using DRJ's code,

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
        If CloseMode = 0 Then
            Cancel = True
            Me.Hide
        End If
        UserForm1.Show False
    End Sub


    See Attached:
    Justin Labenne

  5. #5
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    Quote Originally Posted by Justinlabenne

    Userform#.Show False
    What is the difference between Modal and Modeless Form?
    What will the "false" do?

    Thx

Posting Permissions

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