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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.