G
Guest
I have login form with user name and password. Currently my code works if i
enter correct password and user name it will open form and if password or
name name or both is not valid then it will open msgbox. What i am looking
for is
saperate msgbox for password and user, if user name correct but password not
then i need show msgbox "invalid password" and same thing for user name.
Also if both incorrect then msgbox
"Invalid password a and user name". Please help me out. Thanks.
===============
Private Sub cmdLogin_Click()
On Error GoTo Err_cmdLogin_click
Dim rs As DAO.Recordset
Dim strDesk As String
Dim strPassword As String
Dim stDocName As String
Dim stLinkCriteria As String
Dim strSQL As String
txtDesk.SetFocus
strDesk = txtDesk
txtPassword.SetFocus
strPassword = txtPassword
If Not IsNull(Me.txtDesk) And Not IsNull(Me.txtPassword) Then
Set rs = CurrentDb.OpenRecordset("Select * From tblUsers Where Desk =
'" & strDesk & "' and Password = '" & strPassword & "'", dbOpenSnapshot)
End If
If Not rs.EOF Then
stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
If rs.EOF Then
MsgBox "Invalid Desk Number and Password. Please try again.",
vbCritical, "Invalid Desk Number and Password"
txtDesk = Null
txtPassword = Null
txtDesk.SetFocus
End If
rs.Close
Set rs = Nothing
Exit_cmdLogin_click:
Exit Sub
Err_cmdLogin_click:
MsgBox Err.Description
Resume Exit_cmdLogin_click
End Sub
enter correct password and user name it will open form and if password or
name name or both is not valid then it will open msgbox. What i am looking
for is
saperate msgbox for password and user, if user name correct but password not
then i need show msgbox "invalid password" and same thing for user name.
Also if both incorrect then msgbox
"Invalid password a and user name". Please help me out. Thanks.
===============
Private Sub cmdLogin_Click()
On Error GoTo Err_cmdLogin_click
Dim rs As DAO.Recordset
Dim strDesk As String
Dim strPassword As String
Dim stDocName As String
Dim stLinkCriteria As String
Dim strSQL As String
txtDesk.SetFocus
strDesk = txtDesk
txtPassword.SetFocus
strPassword = txtPassword
If Not IsNull(Me.txtDesk) And Not IsNull(Me.txtPassword) Then
Set rs = CurrentDb.OpenRecordset("Select * From tblUsers Where Desk =
'" & strDesk & "' and Password = '" & strPassword & "'", dbOpenSnapshot)
End If
If Not rs.EOF Then
stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
If rs.EOF Then
MsgBox "Invalid Desk Number and Password. Please try again.",
vbCritical, "Invalid Desk Number and Password"
txtDesk = Null
txtPassword = Null
txtDesk.SetFocus
End If
rs.Close
Set rs = Nothing
Exit_cmdLogin_click:
Exit Sub
Err_cmdLogin_click:
MsgBox Err.Description
Resume Exit_cmdLogin_click
End Sub