none
Need to click a button twice for the user form to hide RRS feed

  • Question

  • I have a small userform that ask an user for his user and password.

    The form contains also a "Submit" button to pass the values entered.

    Strangely, when I fill in the fields and click "Submit", the form does not disappear unless I click twice in the "Submit" button. This behaviour is pretty annoying.

    The form contains the following code:

    Private Sub user_Change()
    'Some actions I perform when the text is changed
    End Sub
    
    Public Sub UserForm_Initialize()
    LoginForm.Show
    End Sub
    
    Private Sub submit_Click()
    LoginForm.Hide
    End Sub

    The form is called from another module using the following line:

    LoginForm.UserForm_Initialize

    What am I doing wrong?

    The other question I'd like to ask is: how can I definitely close the form if the user clicks in the "X" button in the up-right corner of the form?

    Thursday, March 16, 2017 7:18 PM

All replies

  • Hi avalyn3,

    1. I reproduced your issue.
        So, I changed  "LoginForm.Show" to "LoginForm.Show vbModeless".
        This worked fine, i.e. once [submit] clicked, then UserForm closed.
        
    Public Sub UserForm_Initialize()
    LoginForm.Show  vbModeless
    End Sub
    2. [note]
          ".Hide" does make only the form invisible.
          If you want to remove the form from memory, use "Unload". 
    Regards,
    Ashidacchi
    Friday, March 17, 2017 3:38 AM