Please Help With Runtime Error '3061': Too few parameters. Expected 1

K

kenry8705

When I run the code below I receive the Runtime Error '3601': too few
parameters. Expected 1.

Private Sub Cmd_Click()
strInput = Text1.Text
strSQL = "SELECT * FROM AUTO WHERE Name = strInput"
Data1.RecordSource = strSQL
Data1.Refresh
End Sub

Someone Please Help!! I've gone through everyone else's problems w/
this error and cant seem to find any that help my situation.
 
A

Allen Browne

You need to concatenate the value of the text box into the string.

Since the field is called Name, I will assume it is a Text type field, and
therefore needs the quote delimiters:
strSQL = "SELECT * FROM AUTO WHERE Name = """ & Me.Text1 & """;"

You will get away with it in this context but a field called Name is a very
bad idea. Nearly everything in Access has a Name property: forms, reports,
controls, tables, queries, etc. So when you put this text box on a form and
refer to Name, Access is likely to understand it as the name of the form
instead of the contents of the control named Name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top