Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Userform "X" close button not working second round

  1. #11
    New Member
    Join Date
    Jan 2018
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform "X" close button not working second round

    Hi all

    Ok, I got this working with the close button now closing the form the second time and beyond. Good job eduzs!

    However, I'm stuck with referring to the userform from outside of the userform. I used to be able to refer back to it using the userform's name, however it seems that link is now broken. Something to do with the
    Code:
    Set MyForm = New Userform2
    i'm guessing.

    I've tried MyForm but that's not much chop either.

    Train of code:

    DATA_DUMP_PAGE UserForm
    Code:
    Private Sub DELETE_BUTTON_Click()
    
    Application.ScreenUpdating = False
    
    
    Dim MyForm As ADD_DEL_MAT_SHEET
    Me.Hide
    Set MyForm = New ADD_DEL_MAT_SHEET
    MyForm.Show
    Set MyForm = Nothing
    
    
    End Sub
    ADD_DEL_MAT_SHEET UserForm
    Code:
    Private Sub Delete_Material_Button_Click()
    
    Application.ScreenUpdating = False
    
    
    TRANSACTION_TEXT_BOX.Visible = True
    Add_Material_Button.Visible = False
    Delete_Single_Material_Questions
    
    
    End Sub
    Delete-Single_Material-Question()
    Code:
    Sub Delete_Single_Material_Questions()    
            Answer = MsgBox("YOU ARE ABOUT TO DELETE A MATERIAL LINE. ARE YOU SURE?", vbYesNo + vbQuestion + vbMsgBoxSetForeground, "TIME TO TAKE OUT THE TRASH?")
            
            If Answer = vbYes Then
                
                ADD_DEL_MAT_SHEET.TRANSACTION_TEXT_BOX.Visible = False
                ADD_DEL_MAT_SHEET.PHOTO_BLANK_TEXT.Visible = False
                ADD_DEL_MAT_SHEET.PHOTO_BLANK.Visible = False
                Application.ScreenUpdating = True
    When the ADD_DEL_MAT_SHEET userform initially displays it has these three things set as Visible = True - and they are. Run the macros thru to what you see here and nothing changes, however the macro continues on, it doesn't error out there.

    Eventually it does error out when it comes to:
    Code:
    ADD_DEL_MAT_SHEET.Hide
    It gives error:
    Run-time error '402':
    Must close or hide topmost modal first
    Any ideas anyone?

    Cheers
    Chris
    Last edited by Raptor6L; Apr 22nd, 2019 at 03:30 AM.

  2. #12
    New Member
    Join Date
    Jan 2018
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform "X" close button not working second round

    Ok, i figured it out.

    To refer back to the userform you need to create a public sub that contains the instructions within the userform, and refer to that public sub name from outside of the userform to execute those instructions.

    Hope that makes sense?

    Cheers
    Chris

Some videos you may like

User Tag List

Tags for this Thread

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
  •