I have this piece of code to verify a user log in an access form.
stUid = Pw_Count(txtUserID, txtPw)
If stUid = 1 Then
stDocName = "AAAAA"
DoCmd.OpenForm stDocName, , , stLinkCriteria
MsgBox ("Invalid password or user name")
The pw_count function is written like this
Function Pw_Count(inId As String, inPw As String)
Dim SqlStr As String
Dim StrId As String
Dim StrPw As String
Dim rst As DAO.Recordset
StrId = inId
StrPw = InPw
SqlStr = "SELECT count(*) as uCount FROM users WHERE user_Name = StrId and password = StrPw"
Set rst = CurrentDb.OpenRecordset(SqlStr, dbOpenDynaset)
Pw_Count = rst!uCount
Set rst = Nothing
I am getting a run time error (Too few parameters. Expected 2) after executing the function. And it returns nothing. When I step through the code, I notice that the SQL part may not be returing a value. I am thinking the count(*) is not working.