Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime Error 3061: Too Few Parameters expected 1 1

Status
Not open for further replies.

kjv1611

New member
Jul 9, 2003
10,758
US
I can't figure out just what is causing this problem.

Here is the information:

First, the VBA code giving the error:

The line with the error is [HIGHLIGHT]highlighted[/HIGHLIGHT].
Code:
Private Sub cboEndVerse_LostFocus()
  Dim rst As Recordset, x As Long
  Dim strSQL As String
  Dim lngID As Long
  Dim CR As String
  Dim TB As String
  Dim ctl As Control
  CR = Chr(13)
  TB = Chr(9)
  strSQL = "SELECT COUNT(PassageID) AS 'Passages'" & CR & _
           "FROM tblPassages" & CR & _
           "WHERE (BookID = " & cboBook & ") AND " & CR & TB & _
           "(BeginningChapter = " & cboBeginChapter & ") AND " & CR & TB & _
           "(BeginninngVerse = " & cboBeginVerse & ") AND " & CR & TB & _
           "(EndingChapter = " & cboEndChapter & ") AND " & CR & TB & _
           "(EndingVerse = " & cboEndVerse & ")"

  Debug.Print strSQL
  [HIGHLIGHT]Set rst = CurrentDb.OpenRecordset(strSQL)[/HIGHLIGHT]

The error message:
Code:
Run-time error '3061':

Too few parameters. Expected 1.

Any clues as to what is causing the error?

Thanks for any suggestions.

--

"If to err is human, then I must be some kind of human!" -Me
 
Why the single quotes here ?
SELECT COUNT(PassageID) AS 'Passages'

Are BookID, BeginningChapter, BeginninngVerse, EndingChapter and EndingVerse ALL defined as numeric ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Why the tab & lineFeed? ...loose them!

As PHV said, ...no quotes around alias (optional square brackets).
And, are Chapter & verse numeric, your code implies they are.


strSQL = "SELECT COUNT(PassageID) AS [Passages]" _
" FROM tblPassages" & _
" WHERE (BookID = " & cboBook & ") AND " & _
"(BeginningChapter = '" & cboBeginChapter & "') AND " & _
"(BeginninngVerse = '" & cboBeginVerse & "') AND " & _
"(EndingChapter = '" & cboEndChapter & "') AND " & _
"(EndingVerse = '" & cboEndVerse & "')"
 
PHV said:
Why the single quotes here ?
SELECT COUNT(PassageID) AS 'Passages'

That's the way I've done Aliases in SQL on a SQL Server, and so I thought it would be the same here. And actually, I was getting the same error before ever adding an Alias.

PHV said:
Are BookID, BeginningChapter, BeginninngVerse, EndingChapter and EndingVerse ALL defined as numeric ?
Yes. These are all numeric. I had originally had the single quotes in the statement for those, and took them out, thinking that was causing the error, but it did not, apparently.

Zion7 said:
Why the tab & lineFeed? ...loose them!

Actually, the error was there prior to the line feed and tab were added. And those have caused no problems. The reason I add them is so that it is easier to see the whole SQL statement when I "print" it in code for review.

I've tried with and without. These are not the problems.

But thanks for trying..

--

"If to err is human, then I must be some kind of human!" -Me
 
when I "print" it in code for review
Why not posting the generated SQL code raising the error ?

BTW, are PassageID, BookID, BeginningChapter, BeginninngVerse, EndingChapter and EndingVerse ALL defined in tblPassages ?

This is suspicious: Beginnin[!]n[/!]gVerse

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Did you say "Suspicious", PHV?
I'm going to say, rather incriminating!(LOL)...

unless any of the combo boxes, aren't populated,
then i think you hit the nail on the head.


...Good work Sherlock!
 
Well, I was trying to post this last night, but Tek-Tips was having server properties, apparently, and I just gave up, as I wasn't going to wait all night. [wink]

Anyway, Yes, PHV, the typo was the problem. That fixed that little deal up just perfectly.

All the others were not problems, and I knew that for sure, b/c I had tried with and without each and every one of the others.

Now I have a different problem with the same code, however, a little further down. I'm not looking at the code, as it's at my house, and I'm at work, but I remember what it is:

I posted that problem at thread705-1356369

--

"If to err is human, then I must be some kind of human!" -Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top