これは私のコードです PLS ヘルプ
({ユーザー名の表示方法!!})
ユーザー名の代わりにユーザー ID が常に表示されます。コードにミスがあると思います。助けてください。
Option Compare Database
Private Sub BTNCancel_Click()
Dim Ans As String
Ans = MsgBox("Do you want to cancel log-in?", vbYesNo, "Shutdown the system")
If Ans = vbYes Then
DoCmd.Quit
Else
Exit Sub
End If
End Sub
Private Sub CBOEmployee_AfterUpdate()
'After selecting user name set focus to password field
Me.TXTPassword.SetFocus
End Sub
Private Sub BTNLogin_Click()
If IsNull(Me.CBOEmployee) Or Me.CBOEmployee = "" Then
MsgBox "You must Enter a User Name.", vbOKOnly, "Required Data"
Me.CBOEmployee.SetFocus
Exit Sub
End If
If IsNull(Me.TXTPassword) Or Me.TXTPassword = "" Then
MsgBox "You must Enter a Password.", vbOKOnly, "Required Data"
Me.TXTPassword.SetFocus
Exit Sub
End If
If Me.TXTPassword.Value = DLookup("UserPassword", "tblUsers", "[UserID] =" & Me.CBOEmployee.Value) Then
UserID = Me.CBOEmployee.Value
DoCmd.Close acForm, "frmLogon"
DoCmd.OpenForm "frmStudSubject"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.TXTPassword.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You are unauthorized to access this system...Please Contact Your System Administrator.", vbCritical, "Restricted access!"
Application.Quit
End If
End Sub