I am trying to work with the following code I found online for a login Username/Password Userform. When I correctly enter the username and password I get Run Time Error '448': Named argument not found. I have also attached a sample workbook.
Private Sub CommandButton3_Click()
Dim RowNo As Long
Dim Id As String, pw As String
Dim ws As Worksheet
Dim aCell As Range
On Error GoTo ErrorHandler
If Len(Trim(Me.Username.Value)) = 0 Then
Me.Username.Value.SetFocus
MsgBox "Username cannot be empty"
Exit Sub
End If
If Len(Trim(Password)) = 0 Then
Password.SetFocus
MsgBox "Password cannot be empty"
Exit Sub
End If
Application.ScreenUpdating = False
Set ws = Worksheets("User")
Id = LCase(Me.Username.Value)
Set aCell = ws.Columns(1).Find(What:=Id, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
'~~> If match found
If Not aCell Is Nothing Then
RowNo = aCell.Row
If Me.Password = aCell.Offset(, 1) Then
AddRows.Show
Unload Me
Else
MsgBox "Unable to match UserID or PasswordID, Please try again", vbOKOnly
End If
Else '<~~ If not found
MsgBox "Unable to match UserID or PasswordID, Please try again", vbOKOnly
End If
CleanExit:
Set ws = Nothing
Application.ScreenUpdating = True
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume CleanExit
End Sub
Thank you for you help,
James
Bookmarks