Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Errors + Error Handling _ Run-time Error '3061' - Too Few Parameters. Expected 1

Posted by: dzoker Nov 20 2019, 09:13 AM

Hi there,

I have this code

QUOTE
Private Sub cmdCreateQuestions_Click()

Dim s As String, mNum As Integer

If Me.Dirty Then Me.Dirty = False

mNum = Me.sfrmQuestionsAnswers.Form.Recordset.RecordCount

s = "INSERT INTO tblAnswers ( QuestionID, EmployeeID )" _
& " SELECT QuestionID, " & Me.EmployeeID _
& " FROM tblQuestions " _
& " WHERE tblQuestions.SurveyID & Me.cmbSurvey.value;"
Debug.Print s
CurrentDb.Execute s

Me.sfrmQuestionsAnswers.Requery

MsgBox Me.sfrmQuestionsAnswers.Form.Recordset.RecordCount - mNum _
& " Questions added", , "Done"


End Sub


I'm getting an error 3061 "Too few parameter. Expect 1" on CurrentDb.Execute s.

What I'm trying to do is pass the value of cmbSurvey as value as where clause


Posted by: GroverParkGeorge Nov 20 2019, 09:39 AM

The problem appears to be here:

...& " WHERE tblQuestions.SurveyID & Me.cmbSurvey.value;"

What are you trying to filter on here?

A WHERE clause should be something like

WHERE tblQuestions.SurveyID = " & Me.cmbSurvey & ";"

That's based on the assumption SurveyID is a Long Integer and the bound column in that combo box, cmbSurvey is also a Long Integer, presumably that same SurveyID, in fact.

You really don't have to specify ".value" since that's the default property.

Posted by: dzoker Nov 20 2019, 09:46 AM

George,

QUOTE
WHERE tblQuestions.SurveyID = " & Me.cmbSurvey & ";"

is right!

Excuse my dumbness...I guess I had a brain freeze.

I had it like that before the only difference was the I didn't had ";" but just ;" and was getting a different error so I was trying something else.

Sorry for wasting your time but greatly appreciated!


Posted by: GroverParkGeorge Nov 20 2019, 10:11 AM

Not a waste of time at all. Sometimes the "second set of eyes" approach is the best.

Continued success with the project.