I have made a user login form in Excel 2019, using following code:
Private Sub CommandButton1_Click()
If TextBox1.Text = Sheets("D").Range("I14") And TextBox2.Text = Sheets("D").Range("J14") Then MsgBox "Welcome to Ambipix Accounting System" Application.Visible = True Unload Me Sheets("DB").Select Range("A2").Select Else MsgBox "Username or Password is incorrect" Unload UserForm1 UserForm1.Show End If End Sub
But, the problem is that, if i close the form by "QueryClose", in the time of next opening the, User login login form is not opening, rather the workbook opens.
To stop opening the workbook i tried the code:
Private Sub Workbook_Open() Application.Visible = False UserForm1.Show