UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Run-time Error '3061' - Too Few Parameters. Expected 1, Access 2013    
 
   
dzoker
post Nov 20 2019, 09:13 AM
Post#1



Posts: 434
Joined: 12-February 14



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

Go to the top of the page
 
GroverParkGeorge
post Nov 20 2019, 09:39 AM
Post#2


UA Admin
Posts: 36,175
Joined: 20-June 02
From: Newcastle, WA


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.

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
dzoker
post Nov 20 2019, 09:46 AM
Post#3



Posts: 434
Joined: 12-February 14



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!

Go to the top of the page
 
GroverParkGeorge
post Nov 20 2019, 10:11 AM
Post#4


UA Admin
Posts: 36,175
Joined: 20-June 02
From: Newcastle, WA


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

Continued success with the project.

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    9th December 2019 - 08:00 AM