Solved

Access 2007 Receiving Run-time error '3061'

Posted on 2012-12-20
11
395 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 500 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

738 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