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

  • Thread starter Thread starter kenry8705
  • Start date Start date
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.
 
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.
 
Back
Top