Visual basic Run-time error '3061' Too few parameters, Expected 1

BobRoss

New member
Local time
Today, 06:24
Joined
May 8, 2010
Messages
4
I commented out lines in the codebuilder one by one to determine which were and weren't working, see comments in brackets below:

Code:
Private Sub ReportButton_Click()

    Dim varItem As Variant

        For Each varItem In Me.ReportList.ItemsSelected

            CurrentDb.Execute Me.ReportList.Column(2, varItem)    <This runs a  delete query and works.>
            CurrentDb.Execute  Me.ReportList.Column(3, varItem)    <This also runs a delete query  and works.>
            CurrentDb.Execute Me.ReportList.Column(4,  varItem)    <This runs an append query and DOES NOT work; its  highlighted in the code builder>
            CurrentDb.Execute  Me.ReportList.Column(5, varItem)    <This also runs an append query  and DOES NOT work; its highlighted in the code builder>
            DoCmd.OpenReport Me.ReportList.Column(6, varItem), acViewReport     <This opens a report and works.>

        Next varItem

End  Sub
I can run the append queries manually and they all work fine. The column references in the code are also matched correctly to the columns in the listbox.

So I guess you can't use CurrentDB.Execute to run append queries?

Thank you for any ideas of what may be wrong. Always appreciated.
 
I normally always use .Execute for action query. This includes appends.

The issue is that you can not use form references for parameters.

I use DAO to modify the QueryDef before the Execute.
 
Can you please walk me through "using DAO to modify the QueryDef"? Maybe an example of how you do this to run append queries from form references?

It's just strange that CurrentDB.Execute works with delete queries and not append queries.
 
Can you please walk me through "using DAO to modify the QueryDef"? Maybe an example of how you do this to run append queries from form references?

It's just strange that CurrentDB.Execute works with delete queries and not append queries.

do your delete queries have parameters that are form references?
 
Google is showing to wrap the form references in Eval()? Good idea bad idea?
 
Funny, I had this issue a few days ago, and I've seen a similar post also in the last day or so.

Instead of using a form reference, you could store the value in a global variable, and get the query to read it from there. Then you dont get the problem.
 
In a shocking departure from my standard brevity... I went on (and on) about the subject in general over the way at this thread.
The advantage of that thread is it has some links found by Brent - and his take on things (as he is an advocate of the Eval method).

In particular, I advocate the use of a replacement function (i.e. instead of explicitly using OpenRecordset).
An example of which (and its use) can be found here.

Fundamentally, there's no requirement to switch your parameters all out to make an Eval call.

Have a read - see what you think.

Cheers.
 

Users who are viewing this thread

Back
Top Bottom