Hi,

I putting together a workbook that will require the user to enter a User Id and Password in order to gain access. Their are two different levels of security the User and Admin. Admin = 1 and User = 2. Here is the code I have in place so far:

[VBA]Option Explicit
Option Compare Binary

Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()

Dim vUser As Variant
Dim sPw As String

' find the name in name col
On Error Resume Next
vUser = WorksheetFunction.Match(Me.txtUserName.Value, wksUsers.Range("B4:B6"), 0)

If Err.Number <> 0 Then
Me.txtUserName.Value = ""
Me.txtPassword.Value = ""
MsgBox "Login information is incorrect."
Exit Sub
End If

On Error GoTo 0

' if user name is good, get the password.
sPw = WorksheetFunction.Index(wksUsers.Range("c4:c6"), CInt(vUser))

If Err.Number <> 0 Then
'MsgBox "Password name is incorrect."
Me.txtPassword.Value = ""
Me.txtUserName.Value = ""
Exit Sub
End If

If sPw = Me.txtPassword Then
'MsgBox "Login information is correct."
giROLE = WorksheetFunction.Index(wksUsers.Range("d4:d6"), CInt(vUser))
If giROLE = 1 Then HideUnhideAdminSheets True
Else
'MsgBox "Bad"
MsgBox "Login information is incorrect."

End If

ExitHere:
Unload Me
Exit Sub

ErrorHandler:
MsgBox Err.Number
Resume ExitHere

End Sub
Private Sub UserForm_Click()
End Sub[/VBA]

What I want to do is be able to change users without exiting the program. So if an Admin level user is logged in and wants a user with User level access to take over I would like them to be able to do so without exiting and logging back in. I haven't had any luck setting this up. Can anyone help with this?

Thank you.