我有一个访问表单,其中包含UserNameID
文本框和PasswordID
文本框以及Login
按钮,它们仅适用于文本,但当我输入密码作为数字或字符时,它会显示一条消息说明密码错误。因此,我的代码中存在遗漏或需要更正的内容以识别字符或数字。
我们非常感谢您的协助
Private Sub Login_Click()
Dim UserName As String
Dim Password As Integer
Dim FindRow As Range
On Error Resume Next
If Me.UserNameID = "" Then
MsgBox "you have to enter password"
Exit Sub
End If
UserName = Me.UserNameID.Value
Password = Me.PasswordID.Value
Me.PasswordID.MaxLength = 14
Me.PasswordID.PasswordChar = "*"
'find the name of the employee written on the search box in column A
Set FindRow = Sheets("Login Information").Range("A:A").Find(what:=UserName, LookIn:=xlValues)
If Not FindRow Is Nothing And Me.PasswordID.Value = FindRow.Offset(0, 1).Value Then
PayrollandStaffMainForm.Show
Else
MsgBox "The Password you entered is wrong, please try again"
Exit Sub
End If
End Sub