Why wont the userform unload?
Prep for a pre-employment Excel test with Job Test Prep
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Why wont the userform unload?

  1. #1
    Guest

    Default

     
    Hi-
    I designed a project with about 24 userforms. Most of them assign a value to a spreadsheet. The others are for the purpose of selecting a choice to show another userform(By way of a module). Im using optionbutton controlls for these few. Heres the code for one of them:


    Sub CommandButton3_Click()

    'On Error Resume Next
    If OptionButton1.Value = True Then Me.Hide
    If OptionButton1.Value = True Then Call Module1.sheet1

    'On Error GoTo 0
    'On Error Resume Next
    If OptionButton2.Value = True Then Me.Hide
    If OptionButton2.Value = True Then Call Module1.sheet2

    'On Error GoTo 0
    'On Error Resume Next
    If OptionButton3.Value = True Then Me.Hide
    If OptionButton3.Value = True Then Call Module1.sheet3

    'On Error GoTo 0
    'On Error Resume Next
    If OptionButton4.Value = True Then Me.Hide
    If OptionButton4.Value = True Then Call Module1.sheet4

    'On Error GoTo 0

    Unload Me
    End Sub


    Heres the problem- when a certian sequence of userforms are promped to be shown or unloaded, the userforms with the optionbuttons hid and unload initialy, but come back (show) at some other point! If I dont use the error method, I get an error during the sequence, using the error method, the form just reappears. Ive tried everthing to pinpoint the problem. I replaced the optionbutton with a commandbutton to see the results and it works as it should. When I went back to using the optionbutton, I got an error. Im convinced its the way I wrote the code for the optionbuttons, but im not sure how to correct it- please help??

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,169
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi

    Try:

    Unload MyUserForm

    try after each not just at end so will act as kill.

    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  3. #3
    Guest

    Default

      
    Still doesnt work.


    Sub CommandButton3_Click()
    Me.Hide

    'On Error Resume Next
    'If OptionButton1.Value = True Then Me.Hide
    If OptionButton1.Value = True Then Call Module1.sheet1
    Unload Me
    'On Error GoTo 0
    'On Error Resume Next
    'If OptionButton2.Value = True Then Me.Hide
    If OptionButton2.Value = True Then Call Module1.sheet2
    Unload Me
    'On Error GoTo 0
    'On Error Resume Next
    'If OptionButton3.Value = True Then Me.Hide
    If OptionButton3.Value = True Then Call Module1.sheet3
    Unload Me
    'On Error GoTo 0
    'On Error Resume Next
    'If OptionButton4.Value = True Then Me.Hide
    If OptionButton4.Value = True Then Call Module1.sheet4
    Unload Me
    'On Error GoTo 0

    Unload Me
    End Sub


    Any other sugestions?????

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com