I am receiving error code [3061] too few parameters. Expected 1. I can't seem to find the issue. The error code occurs when on this line of code: -
Set rstTemp = CurrentDb.OpenRecordset("sql_Approvers_to_MktPlacePOs")
-
The entire code is as follows: -
Private Sub Create_tbl_DistinctPOsApprovers()
-
-
On Error GoTo Err_Hndlr
-
-
strPO_TEMP = " "
-
strApprover_Level_TEMP = " "
-
strApprover_Username_TEMP = " "
-
strApprover_Last_Name_TEMP = " "
-
strApprover_First_Name_TEMP = " "
-
-
-
'Delete temporary table
-
DoCmd.RunSQL "DROP TABLE tbl_DistinctPOsApprovers;"
-
-
-
CurrentDb.Execute ("CREATE TABLE tbl_DistinctPOsApprovers(PO VARCHAR(14), Approver_Level numeric, Approver_Username VARCHAR(20), Approver_Last_Name VARCHAR(30), Approver_First_Name VARCHAR(30))")
-
-
'Bind rstTemp to the temporary table
-
Set rstTemp = CurrentDb.OpenRecordset("sql_Approvers_to_MktPlacePOs")
-
Set rstSummary = CurrentDb.OpenRecordset("tbl_DistinctPOsApprovers")
-
-
-
rstTemp.MoveFirst
-
-
Do While rstTemp.EOF = False
-
If rstTemp!PO <> strPO_TEMP Then
-
strPO_TEMP = rstTemp!PO
-
strApprover_Level_TEMP = rstTemp!Approver_Level
-
strApprover_Username_TEMP = rstTemp!Approver_Username
-
strApprover_Last_Name_TEMP = rstTemp!Approver_Last_Name
-
strApprover_First_Name_TEMP = rstTemp!Approver_First_Name
-
-
'*** write record
-
rstSummary.AddNew
-
rstSummary!PO = strPO_TEMP
-
rstSummary!Approver_Level = strApprover_Level_TEMP
-
rstSummary!Approver_Username = strApprover_Username_TEMP
-
rstSummary!Approver_Last_Name = strApprover_Last_Name_TEMP
-
rstSummary!Approver_First_Name = strApprover_First_Name_TEMP
-
rstSummary.Update
-
-
' Debug.Print Forms!F_PR_Status!txb_Start_Date; " "; Forms!F_PR_Status!txb_End_Date
-
-
'*** assign temp values
-
' strProductNumber_TEMP = rstTemp!ProductNumber
-
' strProductDescription_TEMP = rstTemp!ProductDescription
-
'*** clear out fields
-
-
strApprover_Level_TEMP = " "
-
strApprover_Username_TEMP = " "
-
strApprover_Last_Name_TEMP = " "
-
strApprover_First_Name_TEMP = " "
-
-
End If
-
-
rstTemp.MoveNext
-
Loop
-
-
-
rstTemp.Close
-
rstSummary.Close
-
-
Create_tbl_DistinctPOsApprovers_Exit:
-
Exit Sub
-
-
-
Err_Hndlr:
-
MsgBox "[" & Err.Number & "]: " & Err.Description, vbInformation, "Create_tbl_DistinctPOsApprovers()"
-
End Sub
-
6 12409
Hi. There are two different types of recordset available in Access: Data Access Objects (the built-in recordsets in Access) and ActiveX Data Objects (ADOX). Unfortunately the two recordset types use different methods, and the error message you are getting on the Openrecordset method is typical if in fact an ADO recordset is implicitly declared when a DAO recordset type is being expected.
To overcome this you will need to qualify the declaration of your recordsets (which I do not see in the code you provided): - Dim rstTemp as DAO.Recordset
-
Dim rstSummary as DAO.Recordset
To avoid compilation errors you must make sure you have a reference set to the MS DAO object library - from the VBA Editor select Tools, References and ensure that you have a tick under the Microsoft DAO 3.6 library (or its equivalent).
-Stewart
If you run sql_Approvers_t o_MktPlacePOs on its own then it will ask you about the criteria you have in the query. If you have something like: BETWEEN [forms]![YourForm]![DateFrom] AND [forms]![YourForm]![DateTo] then your solution would look like this: -
Dim db as DAO.Database
-
Dim qdf as DAO.Querydef
-
Dim rstTemp as DAO.Recordset
-
Set db = CurrentDb()
-
Set qdf = db.QueryDefs("sql_Approvers_to_MktPlacePOs")
-
qdf.Parameters(0) = Forms!YourForm!DateFrom
-
qdf.Parameters(1) = Forms!YourForm!DatoTo
-
Set rstTemp = qdf.OpenRecordset
-
Good morning,
The code declared both record sets as DAOs and the VBA Editor had select the Microsoft DAO 3.6 library (or its equivalent). And the issue still occurred.
please post the SQL for sql_Approvers_t o_MktPlacePOs, which is what is being opened as a recordset.
Please note that if you have a reference to a form control in the Where clause of the query this can cause the 'too few parameters' failure you mention.
-Stewart
Yes, it was the form that was generating this error. thank you for your assistance. when it was declared, the error code went away....
i appreciate your help.
I am receiving an error now "[3265]: Item not found in the collection" at the line below. The value of Forms!F_Waiver_ Yr!Txt_Waiver_Y r is 10. -
qdf.Parameters(0) = Forms!F_Waiver_Yr!Txt_Waiver_Yr
-
The code is as follows: -
Private Sub Create_tbl_DistinctPOsApprovers()
-
-
On Error GoTo Err_Hndlr
-
-
-
Dim qdf As DAO.QueryDef
-
Dim dbs As DAO.Database
-
Dim rstTemp As DAO.Recordset
-
-
Set dbs = CurrentDb()
-
-
-
' when query are used with form parameters, they must be declared in procedures as follows:
-
-
Set qdf = dbs.QueryDefs("sql_Approvers_to_MktPlacePOs")
-
qdf.Parameters(0) = Forms!F_Waiver_Yr!Txt_Waiver_Yr
-
Set rstTemp = qdf.OpenRecordset
-
-
-
-
strPO_TEMP = " "
-
strApprover_Level_TEMP = " "
-
strApprover_Username_TEMP = " "
-
strApprover_Last_Name_TEMP = " "
-
strApprover_First_Name_TEMP = " "
-
-
'**** create output table
-
'Delete temporary table
-
DoCmd.RunSQL "DROP TABLE tbl_DistinctPOsApprovers;"
-
-
'Create temporary table
-
CurrentDb.Execute ("CREATE TABLE tbl_DistinctPOsApprovers(PO VARCHAR(14), Approver_Level numeric, Approver_Username VARCHAR(20), Approver_Last_Name VARCHAR(30), Approver_First_Name VARCHAR(30))")
-
-
'Bind rstTemp to the temporary table
-
'Set rstTemp = CurrentDb.OpenRecordset("tbl_BlankWaiver_Approvers")
-
-
Set rstSummary = CurrentDb.OpenRecordset("tbl_DistinctPOsApprovers")
-
-
-
rstTemp.MoveFirst
-
-
Do While rstTemp.EOF = False
-
If rstTemp!PO <> strPO_TEMP Then
-
strPO_TEMP = rstTemp!PO
-
strApprover_Level_TEMP = rstTemp!Approver_Level
-
strApprover_Username_TEMP = rstTemp!Approver_Username
-
strApprover_Last_Name_TEMP = rstTemp!Approver_Last_Name
-
strApprover_First_Name_TEMP = rstTemp!Approver_First_Name
-
-
'*** write record
-
rstSummary.AddNew
-
rstSummary!PO = strPO_TEMP
-
rstSummary!Approver_Level = strApprover_Level_TEMP
-
rstSummary!Approver_Username = strApprover_Username_TEMP
-
rstSummary!Approver_Last_Name = strApprover_Last_Name_TEMP
-
rstSummary!Approver_First_Name = strApprover_First_Name_TEMP
-
rstSummary.Update
-
-
' Debug.Print Forms!F_PR_Status!txb_Start_Date; " "; Forms!F_PR_Status!txb_End_Date
-
-
'*** assign temp values
-
' strProductNumber_TEMP = rstTemp!ProductNumber
-
' strProductDescription_TEMP = rstTemp!ProductDescription
-
'*** clear out fields
-
-
-
strApprover_Level_TEMP = " "
-
strApprover_Username_TEMP = " "
-
strApprover_Last_Name_TEMP = " "
-
strApprover_First_Name_TEMP = " "
-
-
-
-
End If
-
-
rstTemp.MoveNext
-
Loop
-
-
'*** write last record
-
-
-
-
rstTemp.Close
-
rstSummary.Close
-
-
Create_tbl_DistinctPOsApprovers_Exit:
-
Exit Sub
-
-
-
Err_Hndlr:
-
MsgBox "[" & Err.Number & "]: " & Err.Description, vbInformation, "Create_tbl_DistinctPOsApprovers()"
-
End Sub
-
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dee |
last post by:
Running an AfterUpdate event procedure, I get the following error:
"Too few parameters. Expected 1."
My code is as follows:
Private Sub DealerID_AfterUpdate()
Dim db As DAO.Database
|
by: Miranda Evans |
last post by:
I noticed several postings about issues related to "run-time error
3061", and I observed that the solutions to these issues appear to
involve correcting something within the SQL code. I'm encountering
the "run-time error 3061" issue, but I'm not sure how to go about
correcting the SQL. My hunch is that I have not properly constructed
things to identify a date field, but I don't know how to correct this
issue. In addition to not...
|
by: Steve Richfield |
last post by:
There have been LOTS of postings about error 3061, but mine seems to
be an even simpler case than the others. I have a simple
**FUNCTIONING** query called qryEdits. Copying the SQL from the query,
it reads:
SELECT Edits.Pattern, Edits.From, Edits.To
FROM Edits
WHERE (((Edits.Language)=!.));
The idea is to select just the language-appropriate records from the
|
by: fanfromfla |
last post by:
I am using a database that has worked for many years for a holiday
project for needy families. My organization recently upgraded its
server and changed everyone to Windows XP. I just mention that in case
that has anything to do with the problem.
There are pre-set reports that can be run with this database. I am
getting a Runtime Error 3061 with one of them. It says Too Few
Parameters. Expected 1.
I have tried to trouble-shoot, but am...
|
by: Richard Hollenbeck |
last post by:
I thought I was very specific in this SQL request. There is a form open
with a selected record (and a corresponding "lngRecipeID" on that form. The
table also has a field called "lngRecipeID". But I keep getting this error:
Runtime Error 3061: Too Few Parameters expected 1. What should I be looking
for to fix this?
Here's my code so far:
Private Sub cmdAddIngredientToRecipe_Click()
Dim dbGetRecipeID As DAO.Database
| |
by: Richard Hollenbeck |
last post by:
I wonder what I'm missing?
I really feel like a retard because I've been screwing with some code for a
very long time. I just must be missing something very simple.
In the following example, I've stripped away everything that doesn't cause
the error to make my question a little simpler.
Here's the problem in its simplest form inside a report:
Dim db As DAO.Database
|
by: istya |
last post by:
I am having a dumb day to day. Can anyone have a schufty at my code and see why I am getting the runtime error 3061? I'm working on 2000 if that helps at all.
Dim dbs As DAO.Database
Dim results As DAO.Recordset
Set dbs = CurrentDb
Set results = dbs.OpenRecordset("SELECT COUNT(*) FROM name_check;")
MsgBox (results(0))
'Set results = dbs.OpenRecordset("SELECT division FROM divisions WHERE station= """ + !! + """;")...
|
by: phill86 |
last post by:
Hi,
I am trying to run the following query in a recordset and i get the following error message
Runtime error 3061 - Too few parameters. Expected 1
i am using the following code
|
by: Cintury |
last post by:
The problem is I have a function that I've created and stored in a module. I call it as an expression (e.g. total: Function(parameter)). I'm receiving the error 3061: too few parameters, expected 1. Now the query and database are already open so I'm not entirely sure of any connection strings I may need. I think part of the problem may be that the parameter I am using to call the function is part of the query. I am not sure how to come by this...
|
by: tasawer |
last post by:
Hi,
I need to add a new record to table "ACC_Vehicle", with three pieces of information.
When I activate the code, I get the error "Error 3061, Too few parameters Expected 1"
ACCVehicleID is the Autonumber field.
Reg is a required field.
Your help is appreciated.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |