Run time error '3061'. Too Few parameter. Expected 1.

S

She Wee

I encountered the above error when I have a form running the a query created
in design view.

My form (frmUserLogin) is actually a login form, taking in username and
password from the user. I have a table (User) which stores the username and
passwords of "registered" users and I created a query (validUser) which takes
the value of the txtUsername from frmUserLogin.

Below is my code which is runned when the Login button is being clicked.

Dim dbMyDB As DAO.Database
Dim rsTable As DAO.Recordset
Dim strQuery As String

Set dbMyDB = CurrentDb
Set rsTable = dbMyDB.OpenRecordset("validUser") <-- Encountered the above
error when runned.

Anyone out there can solve this prob?

Thanks a lot in advance. :)


Regards
She Wee
 
D

Duane Hookom

I would use a sql string rather than a saved query:

Dim strSQL as String
strSQL = "SELECT * FROM [User] WHERE username =""" &
Forms!frmUserLogin!txtUserName & """")
Set rsTable = dbMyDB.OpenRecordset(strSQL)


BTW: I would not create an object named "User" since it may be a reserved
word either in Access or other database environments.
 
Top