Run-time Error 3061

Why does the following line give me an error?
Set rst = mydb.OpenRecordset("SELECT * FROM People WHERE Name LIKE Tim", dbOpenDynaset)

The exact error is:
Run-time Error 3061
Too few parameters, Expected 1.

How do I fix it?

I want to be able to pull up all records from the table people that have values in the name field like Tim (i.e.; Timothy, Timmy, etc)....all fields to the records as well, NOT just the name field

Thanks!
LVL 3
grooneAsked:
Who is Participating?
 
Mohammed NasmanConnect With a Mentor Software DeveloperCommented:
Hello

  try this

Set rst = mydb.OpenRecordset("SELECT * FROM People WHERE Name LIKE 'Tim*' ", dbOpenDynaset)

Mohammed
0
 
kirthirCommented:
Change the qry to something like

"SELECT * FROM People WHERE Name LIKE ""Tim*"" "  (starting with Tim)

If you want "Tim" anywhere in the name field then change the query to

"SELECT * FROM People WHERE Name LIKE ""*Tim*"" "  (Tim anywhere in the field)

For a double-quote another double-quote will act as escape character

IF THIS DOESN'T WORK CHANGE * with % in the query and try.

All the best
0
 
hongjunCommented:
Try this

Set rst = mydb.OpenRecordset("SELECT * FROM People WHERE Name LIKE 'Tim%'", dbOpenDynaset)

hongjun
0
 
Mohammed NasmanSoftware DeveloperCommented:
Hello

  try this

Set rst = mydb.OpenRecordset("SELECT * FROM People WHERE Name LIKE 'Tim*' ", dbOpenDynaset)

Mohammed
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.