By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,493 Members | 3,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,493 IT Pros & Developers. It's quick & easy.

Runtime Error 3061: Too Few Parameters expected 1

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.