Hi guys,

I have an access database with a column for usernames and a column for passwords.
I also designed a userform on excel vba with an input box for usernames and an input box for password.

After quite a bit of googling, i've ended up with this code:

Private Sub CommandButton1_Click()

    Dim Username As String
    Username = txtUserNameIn.Text
    Dim password As String
    password = txtPasswordIn.Text
     
    If IsNull(Me.txtUserNameIn) Or Me.txtUserNameIn = "" Then
        MsgBox "You must enter your username.", vbOKOnly, "Required Data"
        Me.txtUserNameIn.SetFocus
        Exit Sub
    End If
     
    
    If IsNull(Me.txtPasswordIn) Or Me.txtPasswordIn = "" Then
        MsgBox "You must enter your Password (case sensitive).", vbOKOnly, "Required Data"
        Me.txtPasswordIn.SetFocus
        Exit Sub
    End If
     
    
    Dim temp As String
On Error Resume Next
temp = WorksheetFunction.VLookup(Me.txtUserNameIn.Value, Range("UserRegister"), 1, 0)
 
If Username = temp Then
     
    Err.Clear
    temp = ""
    temp = WorksheetFunction.VLookup(Me.txtUserNameIn.Value, Range("UserRegister"), 2, 0)
    On Error GoTo 0
    If password = temp Then
        Sheets("ADMIN").Visible = xlSheetVisible
        MsgBox "Password & Username Accepted"
        Unload Me
        Sheets("ADMIN").Select
        Range("A1").Select
    Else
        Sheets("ADMIN").Visible = xlVeryHidden
        MsgBox "Username & Password Combination Not Accepted, Workbook will close"
        Unload Me
            
        End If
    End If
     


End Sub
But I get the error "Method or data member not found".

I am quite new to this so any help is welcomed, thank you !