If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back  dBforums > PC based Database Applications > Microsoft Access > CurrentDB.Execute problems

LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Registered User
Join Date: Mar 2008
Posts: 9
Question CurrentDB.Execute: Too few parameters

Hello, all!

I'm using Access 2002, and I'm running into an issue with using CurrentDB.Execute to run an 'append' query. My code is simply this:

strQueryName = "qry_20_AvgInboundPieces_Monthly_3Count"
CurrentDb.Execute strQueryName, dbFailOnError
When I run it, it gives me this error:

Run-time error '3061':
Too few parameters. Expected 2.

I've verified that the query works by running it other ways. I can double-click on it and it fires off just fine, and it plays nice with DoCmd.OpenQuery. I'm trying to get away from DoCmd.OpenQuery because of having to use SetWarnings False/True to make it not ask me if I'm sure I want to update the table when the query runs. I have read several suggestions other places saying to use CurrentDb.Execute instead, but I cannot get it to work. I've tried it without the dbFailOnError, and I've tried these, both with and without dbFailOnError:

strQueryName = "qry_20_AvgInboundPieces_Monthly_3Count"
CurrentDb.QueryDefs(strQueryName).Execute dbFailOnError

CurrentDb.QueryDefs("qry_20_AvgInboundPieces_Monthly_3Count").Execute dbFailOnError
I'm not sure if this makes any difference, but the query that's trying to run does pull some date data for SQL comparisons from form fields. I've set the form field types to "General Date". I'm not sure if that's correct since some of them have date/time info (9/6/2008 12:00:00AM) and others just have the date (9/6/2008). I've also tried adding the following to the beginning of the SQL itself to see if that made a difference, but it didn't.

"PARAMETERS [Forms]![frmMain]![txtMonthBegin] DateTime, [Forms]![frmMain]![txtMonthEnd] DateTime;"
Other than that, the code seems pretty straight forward, and the query seems to run using just about everything else, so I don't see why it won't run here. Does anyone have any suggestions?


Last edited by thinker5555; 09-06-08 at 11:46.
Reply With Quote
  #2 (permalink)  
King of Understatement
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,910
Originally Posted by thinker5555
I'm not sure if this makes any difference, but the query that's trying to run does pull some date data for SQL comparisons from form fields
Yeah - that makes every difference. You add parameters to the query, and instantiate DAO some parameter objects in your code and use these to pass the values to the query via the querydef object.

I haven't done it for years so can't be much more specific but the above should give you enough to google around - come back if you don't crack it.
pootle flump
ur codings are working excelent.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On