Hi,
I want to restrict access to certain forms by setting a login and password. The login and password information is stored in a table. I need to know how do I check if the login and password are correct when they press the Login button. I want to use VB code. I tried using
Private Sub cmdLogin_Click()
Dim dbs As Database
Dim rstUser_Information As Recordset
Dim strQuery As String
strQuery = "Select * From User_Information Where ((Login ='" & strLogin & "') & (Password ='" & strPassword & "'));"
Set dbs = CurrentDb
Set rstUser_Information = CurrentDb.OpenRecordset(strQuery, dbOpenDynaset)
If Not rstUser_Information.EOF Then
DoCmd.OpenForm "Commissions_Date"
rstUser_Information.Close
Set rstUser_Information = Nothing
Else
MsgBox ("Login failed"
End If
End Sub
This code seems to run even if the the login and password are wrong.
I would be grateful if someone could help me on this.
I want to restrict access to certain forms by setting a login and password. The login and password information is stored in a table. I need to know how do I check if the login and password are correct when they press the Login button. I want to use VB code. I tried using
Private Sub cmdLogin_Click()
Dim dbs As Database
Dim rstUser_Information As Recordset
Dim strQuery As String
strQuery = "Select * From User_Information Where ((Login ='" & strLogin & "') & (Password ='" & strPassword & "'));"
Set dbs = CurrentDb
Set rstUser_Information = CurrentDb.OpenRecordset(strQuery, dbOpenDynaset)
If Not rstUser_Information.EOF Then
DoCmd.OpenForm "Commissions_Date"
rstUser_Information.Close
Set rstUser_Information = Nothing
Else
MsgBox ("Login failed"
End If
End Sub
This code seems to run even if the the login and password are wrong.
I would be grateful if someone could help me on this.