Access VBA - "Runtime error '3061'. Too few parameters. Expected 1.

Can any one tell me why this code gives an error - "Runtime error '3061'. Too few parameters. Expected 1." Debugging window brings me to the line Set rst = dbs.OpenRecordset(sqlstr).

Private Sub cmd_logIn_Click()

Dim user_password As String
Dim user_name As String
Dim sqlstr As String

user_name = Me.txt_logIn_name


sqlstr = "SELECT Users.user_password FROM Users WHERE (((Users.user_name)=[Forms]![frm_log_in]![txt_logIn_name]));"


   ' Comments: Browse a query and display its fields in the Immediate Window using DAO

   Dim dbs As DAO.Database
   Dim rst As DAO.Recordset

   ' Open pointer to current database
   Set dbs = CurrentDb

   ' Open recordset on saved query
   Set rst = dbs.OpenRecordset(sqlstr)

   ' Display data from one record and move to the next record until finished
   'Do While Not rst.EOF
     user_password = rst![user_password]
     'rst.MoveNext
  ' Loop
   
   rst.Close
   dbs.Close


If user_password = Me.txt_password Then
Me.lbl_welcome.Visible = True

Else

Me.lbl_welcome.Visible = False

End If


End Sub
maximyshkaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
change this

sqlstr = "SELECT Users.user_password FROM Users WHERE (((Users.user_name)=[Forms]![frm_log_in]![txt_logIn_name]));"


to


sqlstr = "SELECT Users.user_password FROM Users WHERE (((Users.user_name)='" & [Forms]![frm_log_in]![txt_logIn_name] &"'));"

0
 
Rey Obrero (Capricorn1)Commented:
to see it clearly


sqlstr = "SELECT Users.user_password FROM Users WHERE (((Users.user_name)=" & chr(34) & [Forms]![frm_log_in]![txt_logIn_name] & chr(34)));"

0
All Courses

From novice to tech pro — start learning today.