473,769 Members | 5,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Runtime Error 3061: Too Few Parameters expected 1

I thought I was very specific in this SQL request. There is a form open
with a selected record (and a corresponding "lngRecipeI D" on that form. The
table also has a field called "lngRecipeI D". 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 cmdAddIngredien tToRecipe_Click ()
Dim dbGetRecipeID As DAO.Database
Dim rsGetRecipeID As DAO.Recordset
Dim StrSQL As String

Set dbGetRecipeID = CurrentDb()

StrSQL = "SELECT tblRecipes.lngR ecipeID FROM tblRecipes WHERE
tblRecipes.lngR ecipeID = frmRecipes.lngR ecipeID;"

Set rsGetRecipeID = dbGetRecipeID.O penRecordset(St rSQL, dbOpenDynaset)
MsgBox rsGetRecipeID 'just to test the query before going any further

End Sub
Thanks.
Jun 28 '06 #1
4 7164
Update: I forgot the single and double quotes thing.

New problem: Now I'm getting run time error 3464, data type mismatch in
criteria expression.

Here's what it says now:

Private Sub cmdAddIngredien tToRecipe_Click ()
Dim recipeID As Long
Dim dbGetRecipeID As DAO.Database
Dim rsGetRecipeID As DAO.Recordset
Dim StrSQL As String
Set dbGetRecipeID = CurrentDb()
StrSQL = "SELECT tblRecipes.lngR ecipeID FROM tblRecipes WHERE
tblRecipes.lngR ecipeID = '" & Forms!frmrecipe s.lngRecipeID & "'"
Set rsGetRecipeID = dbGetRecipeID.O penRecordset(St rSQL, dbOpenDynaset)
recipeID = rsGetRecipeID.F ields(0)
MsgBox recipeID ' just to test what I have so far before continuing
End Sub

Jun 28 '06 #2
On Wed, 28 Jun 2006 22:19:10 GMT, "Richard Hollenbeck"
<ri************ ****@verizon.ne t> wrote:
I thought I was very specific in this SQL request. There is a form open
with a selected record (and a corresponding "lngRecipeI D" on that form. The
table also has a field called "lngRecipeI D". 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 cmdAddIngredien tToRecipe_Click ()
Dim dbGetRecipeID As DAO.Database
Dim rsGetRecipeID As DAO.Recordset
Dim StrSQL As String

Set dbGetRecipeID = CurrentDb()

StrSQL = "SELECT tblRecipes.lngR ecipeID FROM tblRecipes WHERE
tblRecipes.lngR ecipeID = frmRecipes.lngR ecipeID;"

Set rsGetRecipeID = dbGetRecipeID.O penRecordset(St rSQL, dbOpenDynaset)
MsgBox rsGetRecipeID 'just to test the query before going any further

End Sub
Thanks.


Concatenate the value of frmRecipes.lngR ecipeID rather than referencing it
directly -

StrSQL = "SELECT tblRecipes.lngR ecipeID FROM tblRecipes WHERE
tblRecipes.lngR ecipeID = " & frmRecipes.lngR ecipeID & ";"
Wayne Gillespie
Gosford NSW Australia
Jun 28 '06 #3
On Wed, 28 Jun 2006 22:39:47 GMT, "Richard Hollenbeck"
<ri************ ****@verizon.ne t> wrote:
Update: I forgot the single and double quotes thing.

New problem: Now I'm getting run time error 3464, data type mismatch in
criteria expression.

Here's what it says now:

Private Sub cmdAddIngredien tToRecipe_Click ()
Dim recipeID As Long
Dim dbGetRecipeID As DAO.Database
Dim rsGetRecipeID As DAO.Recordset
Dim StrSQL As String
Set dbGetRecipeID = CurrentDb()
StrSQL = "SELECT tblRecipes.lngR ecipeID FROM tblRecipes WHERE
tblRecipes.lng RecipeID = '" & Forms!frmrecipe s.lngRecipeID & "'"
Set rsGetRecipeID = dbGetRecipeID.O penRecordset(St rSQL, dbOpenDynaset)
recipeID = rsGetRecipeID.F ields(0)
MsgBox recipeID ' just to test what I have so far before continuing
End Sub


The quotes are only required if lngRecipeID is a string, assuming it is a long
(by your naming convention), you do not need the quotes. See my other post.
Wayne Gillespie
Gosford NSW Australia
Jun 28 '06 #4
"Wayne Gillespie" <be*****@NOhotm ailSPAM.com.au> wrote in message
news:hj******** *************** *********@4ax.c om...
....
The quotes are only required if lngRecipeID is a string, assuming it is a
long
(by your naming convention), you do not need the quotes. See my other
post.

Wayne Gillespie
Gosford NSW Australia


Yeah that did it. Funny that when you step away from VBA for a few months
you can forget a lot. It's like I'm learning it all over again from
scratch. I suspect that within a few days it will all start to come back to
me.

Oh, and yes it is a long; since the Ingredients table has this field as an
AutoNumber which is a long I should keep all secondary keys as long too.

Thank you!

Rich Hollenbeck
Moreno Valley, California USA
Jun 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4439
by: Reggie | last post by:
Hi and TIA! I have a query that uses 2 values from my form as criteria for 2 fields in the query. I can select the options and open the query. I can base a form on the query and launch it from my criteria form with no problem. However if I try to open a recordset object against the query from this same criteria form I receive the (error # 3061 Too few parameters. expected 2.). I've tried first opening the query from code, which worked...
3
4019
by: colm | last post by:
i get the above runtime error on the following line of code when i try to update a reord in my form when it gets to the line Set rs = DBEngine(0)(0).OpenRecordset(strSql) the entire code is posted below
2
5545
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
2
5939
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...
11
3353
by: MLH | last post by:
If this is what MySQL is set to... SELECT DISTINCTROW qryVehiclesNowners5.SerialNum, qryVehiclesNowners5.VDescr, qryVehiclesNowners5.Owner, qryVehiclesNowners5.VehicleJobID , tblVehicleJobs.Reclaimed, tblVehicleJobs.VSaleID, tblVehicleJobs.ENF262Written FROM qryVehiclesNowners5 INNER JOIN tblVehicleJobs ON qryVehiclesNowners5.VehicleJobID = tblVehicleJobs.VehicleJobID WHERE (tblVehicleJobs.Reclaimed=No AND tblVehicleJobs.VSaleID Is Null...
1
22305
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
3
3833
by: Kassimu | last post by:
Hi there, I have a table with thousands of record entries, usually the user searches this table through SearchForm resulting into some recordset. What I need to do on this recordset is to concatenate the contents of all the records for one field-, and populate the resulting into textbox of a form Private Sub Form_Load() Dim db As Database Dim rstUpdates As Recordset Set db = CurrentDb Set rstUpdates = db.OpenRecordset("Daily...
3
4386
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
8
2992
Cintury
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...
0
9589
marktang
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...
0
9423
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,...
0
10211
Oralloy
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...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
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...
0
6673
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();...
0
5299
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...
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.