Can anyone help (please!) What I am trying to do is search a table of user ids and passwords based on a form with two text boxes one contains the user id and the other contains the password the query searches the table for the user ID and returns the user password in the table then I want to compare the value in the second "password" texbox with the returned value to verify it
the code below I keeps giving an error box stting that more parameters were expected
Private Sub Login_Click()
On Error GoTo Err_Login_Click
'declare variables
Dim stUser, stPass As String
Dim DatBas As Database
Dim Records As Recordset
Dim OpQuery As QueryDef
Dim PasVal, stDocName, stLinkCriteria As String
'define the users details from the form
stUser = Operator_Id.value
stPass = Operator_Password
'define database / queries
Set DatBas = CurrentDb()
Set OpQuery = DatBas.CreateQueryDef(""
OpQuery.SQL = "SELECT passwrd FROM ps WHERE Id =" & stUser
OpQuery.ReturnsRecords = True
Set Records = OpQuery.OpenRecordset()
'pass results of query to variable
PasVal = Records!passwrd
If PasVal = stPass Then
DoCmd.close
stDocName = "FrontScreen"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox ("The Operator Id or password you have entered is invalid please try again"
End If
the code below I keeps giving an error box stting that more parameters were expected
Private Sub Login_Click()
On Error GoTo Err_Login_Click
'declare variables
Dim stUser, stPass As String
Dim DatBas As Database
Dim Records As Recordset
Dim OpQuery As QueryDef
Dim PasVal, stDocName, stLinkCriteria As String
'define the users details from the form
stUser = Operator_Id.value
stPass = Operator_Password
'define database / queries
Set DatBas = CurrentDb()
Set OpQuery = DatBas.CreateQueryDef(""
OpQuery.SQL = "SELECT passwrd FROM ps WHERE Id =" & stUser
OpQuery.ReturnsRecords = True
Set Records = OpQuery.OpenRecordset()
'pass results of query to variable
PasVal = Records!passwrd
If PasVal = stPass Then
DoCmd.close
stDocName = "FrontScreen"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox ("The Operator Id or password you have entered is invalid please try again"
End If