Solved

Runtime error '3061': Too few Parameters. Expected 3

Posted on 2008-10-30
6
1,538 Views
Last Modified: 2013-11-27
[qryEditNewSummary] is a Query, If change the [qryEditNewSummary] to a "Table" , It work ok, no error. but if change to any Query, it will have runtime error 3601.
I have check the query name, and field name, everything is ok.

What 's wrong with query in dao??
Private Sub cmdRandom_Click()   
 Dim dbs As Database
    Dim rst As Recordset
        Set dbs = CurrentDb
        strSQL = "Select Total From [qryEditNewSummary]"
        Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
    MsgBox rst!Total
End Sub

Open in new window

0
Comment
Question by:Uncochen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 13

Expert Comment

by:numberkruncher
ID: 22846854
Have you tried the following:
Private Sub cmdRandom_Click()   
 Dim dbs As Database
    Dim rst As Recordset
        Set dbs = CurrentDb
' Without square brackets around qryEditNewSummary
        strSQL = "Select Total From qryEditNewSummary"
        Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
    MsgBox rst!Total
End Sub

Open in new window

0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 22846858
In fact you probably also need to specify where 'Total' comes from.
Private Sub cmdRandom_Click()   
 Dim dbs As Database
    Dim rst As Recordset
        Set dbs = CurrentDb
        strSQL = "Select qryEditNewSummary.Total From qryEditNewSummary"
        Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
    MsgBox rst!Total
End Sub

Open in new window

0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 22846884
This error can also occur when the query requires additional input parameters. I believe that you can specify those using something like the following:
dbs.Parameters![SpecialParm] = "SomeValue"
dbs.Parameters![AnotherParm] = "SomeValue"

Open in new window

0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22848024
Uncochen,

Can you post the SQL for:
qryEditNewSummary
... so we don't have to guess at what the problem is?

JeffCoachman
0
 

Author Comment

by:Uncochen
ID: 22849182
I try to  make a new access file and run, it work Ok!!!
the ado and query no this problem. I don't kown what reason the old file will happen the problem??? I did try to greate a new query in the old file, still problem!!
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 22849454
Like Jeff suggested, the problem may be in qryEditNewSummary.

A very common cause of this error is Form References in a query.

For example, if your query looks like this:
SELECT *
FROM YourTable
WHERE YourField = Forms!YourForm!YourTextboxName

This query will work perfectly when run from the database window. However, the reference to the form control will cause the "Too Few Parameters" Error if that same query is called from VBA.


To resolve this, all form references must be evaluated seperately from the query.
 
To help you further with this, we would need to see the SQL for  qryEditNewSummary.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question