?
Solved

Access 2007 Receiving Run-time error '3061'

Posted on 2012-12-20
11
Medium Priority
?
397 Views
Last Modified: 2012-12-27
Receiving Run-time error '3061' Too few parameters. Expected @ Set rst = CurrentDb.OpenRecordset(strSql). I can't figure out why.

'Total Households Served
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSql As String
Dim vcatch As String
Dim vsql As String

vsql = Me.cboProvider

strSql = "SELECT tblPSHClients.[Entry Exit Provider Id], Count(tblPSHClients.[Client Uid]) AS [CountOfClient Uid] " & vbCrLf & _
"FROM tblPSHClients " & vbCrLf & _
"WHERE (((tblPSHClients.[Household Relate# Head Of Household])<>""No"")) " & vbCrLf & _
"GROUP BY tblPSHClients.[Entry Exit Provider Id] " & vbCrLf & _
"HAVING tblPSHClients.[Entry Exit Provider Id]= " & vsql & ";"

Set rst = CurrentDb.OpenRecordset(strSql)
If Not rst.EOF Then
Me.txtTotalHouseholds = rst![CountOfClient Uid]
Else
'MsgBox "Client" & " " & Me.txtsearch & " " & "does not have a veteran stauts"
Me.txtTotalHouseholds.Value = 0
End If

Set rst = Nothing
Set db = Nothing
0
Comment
Question by:jbakestull
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
11 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 38711641
Scrutinize your table and field names for typos.

This error generally means that one of your field names is unrecognized.
0
 

Author Comment

by:jbakestull
ID: 38711645
I've complied the database and double checked naming, no errors.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38711647
I've also simplified your sql here - you don't need the vbCRLF's:

strSql = "SELECT tblPSHClients.[Entry Exit Provider Id], Count(tblPSHClients.[Client Uid]) AS [CountOfClient Uid] " &  _
"FROM tblPSHClients " &  _
"WHERE tblPSHClients.[Household Relate# Head Of Household] <> 'No' " &  _
"GROUP BY tblPSHClients.[Entry Exit Provider Id] "  & _
"HAVING tblPSHClients.[Entry Exit Provider Id]= " & vsql 

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38711652
Simplified a little more:


strSql = "SELECT [Entry Exit Provider Id], Count([Client Uid]) AS [CountOfClient Uid] " &  _
"FROM tblPSHClients " &  _
"WHERE [Household Relate# Head Of Household] <> 'No' " &  _
"GROUP BY [Entry Exit Provider Id] "  & _
"HAVING [Entry Exit Provider Id]= " & vsql 

Open in new window


Also is Entry Exit Provider Id text or numeric?  
If it is text, use this instead:

strSql = "SELECT [Entry Exit Provider Id], Count([Client Uid]) AS [CountOfClient Uid] " &  _
"FROM tblPSHClients " &  _
"WHERE [Household Relate# Head Of Household] <> 'No' " &  _
"GROUP BY [Entry Exit Provider Id] "  & _
"HAVING [Entry Exit Provider Id]='" & vsql  & "'"

Open in new window


Finally if none of these ideas help try renaming [Household Relate# Head Of Household] to something that does not include any special characters.
0
 

Author Comment

by:jbakestull
ID: 38711657
[Entry Exit Provider Id] is text
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 38711661
vsql is a string
maybe:
"HAVING tblPSHClients.[Entry Exit Provider Id]= '" & vsql & "'"
0
 

Author Comment

by:jbakestull
ID: 38711669
thanks
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38711679
jbakestull,

Did you see my last suggestion for revising your query for a text [Entry Exit Provider Id]?

http:#a38711652
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 38711686
I did not notice that, either.
This should be mbizup's.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question