473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 "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
Dim rsGetRecipeID As DAO.Recordset
Dim StrSQL As String

Set dbGetRecipeID = CurrentDb()

StrSQL = "SELECT tblRecipes.lngRecipeID FROM tblRecipes WHERE
tblRecipes.lngRecipeID = frmRecipes.lngRecipeID;"

Set rsGetRecipeID = dbGetRecipeID.OpenRecordset(StrSQL, dbOpenDynaset)
MsgBox rsGetRecipeID 'just to test the query before going any further

End Sub
Thanks.
Jun 28 '06 #1
4 7150
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 cmdAddIngredientToRecipe_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.lngRecipeID FROM tblRecipes WHERE
tblRecipes.lngRecipeID = '" & Forms!frmrecipes.lngRecipeID & "'"
Set rsGetRecipeID = dbGetRecipeID.OpenRecordset(StrSQL, dbOpenDynaset)
recipeID = rsGetRecipeID.Fields(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.net> wrote:
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
Dim rsGetRecipeID As DAO.Recordset
Dim StrSQL As String

Set dbGetRecipeID = CurrentDb()

StrSQL = "SELECT tblRecipes.lngRecipeID FROM tblRecipes WHERE
tblRecipes.lngRecipeID = frmRecipes.lngRecipeID;"

Set rsGetRecipeID = dbGetRecipeID.OpenRecordset(StrSQL, dbOpenDynaset)
MsgBox rsGetRecipeID 'just to test the query before going any further

End Sub
Thanks.


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

StrSQL = "SELECT tblRecipes.lngRecipeID FROM tblRecipes WHERE
tblRecipes.lngRecipeID = " & frmRecipes.lngRecipeID & ";"
Wayne Gillespie
Gosford NSW Australia
Jun 28 '06 #3
On Wed, 28 Jun 2006 22:39:47 GMT, "Richard Hollenbeck"
<ri****************@verizon.net> 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 cmdAddIngredientToRecipe_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.lngRecipeID FROM tblRecipes WHERE
tblRecipes.lngRecipeID = '" & Forms!frmrecipes.lngRecipeID & "'"
Set rsGetRecipeID = dbGetRecipeID.OpenRecordset(StrSQL, dbOpenDynaset)
recipeID = rsGetRecipeID.Fields(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*****@NOhotmailSPAM.com.au> wrote in message
news:hj********************************@4ax.com...
....
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
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...
3
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...
2
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,...
2
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...
11
by: MLH | last post by:
If this is what MySQL is set to... SELECT DISTINCTROW qryVehiclesNowners5.SerialNum, qryVehiclesNowners5.VDescr, qryVehiclesNowners5.Owner, qryVehiclesNowners5.VehicleJobID ,...
1
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,...
3
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...
3
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
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....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.