G
GGill
If password correct but user not then i see 2 msgboxes 'invalid user name'
and 'invalid user name and password' and same thing if both not correct. What
should i change to view only one msgbox for each incorrect data?
===========================
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
Set rs = CurrentDb.OpenRecordset("Select * From tblUsers Where Desk ='" &
strDesk & "'", dbOpenSnapshot)
If Not rs.EOF Then
If rs!Password = strPassword Then
stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Invalid Password"
End If
Else
MsgBox "Invalid User Name"
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
==============================
and 'invalid user name and password' and same thing if both not correct. What
should i change to view only one msgbox for each incorrect data?
===========================
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
Set rs = CurrentDb.OpenRecordset("Select * From tblUsers Where Desk ='" &
strDesk & "'", dbOpenSnapshot)
If Not rs.EOF Then
If rs!Password = strPassword Then
stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Invalid Password"
End If
Else
MsgBox "Invalid User Name"
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
==============================