Avatar of jbakestull
jbakestull
 asked on

Access 2007 Receiving Run-time error '3061'

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
Microsoft Access

Avatar of undefined
Last Comment
jerryb30

8/22/2022 - Mon
mbizup

Scrutinize your table and field names for typos.

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

ASKER
I've complied the database and double checked naming, no errors.
mbizup

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

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
mbizup

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jbakestull

ASKER
[Entry Exit Provider Id] is text
jerryb30

vsql is a string
maybe:
"HAVING tblPSHClients.[Entry Exit Provider Id]= '" & vsql & "'"
jbakestull

ASKER
thanks
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
mbizup

jbakestull,

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

http:#a38711652
jerryb30

I did not notice that, either.
This should be mbizup's.