Solved

Access 2007 Receiving Run-time error '3061'

Posted on 2012-12-20
11
390 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
  • 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now