I have a query that returns a single value. It runs in Query Analyzer in Access 2000 perfectly. However I need to run this query to populate a text box in a Report. I created a function that returns the value the query returns. Here's the function
Public Function get_Issues(ByRef varProvGrp As String, varProvsubgrp As String) As Long
Dim strsql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
strsql = "SELECT Sum([CT]) AS SumOfCT " & _
"FROM [0008_PCP Transfers by Group - with MM] " & _
"Where ProvGroupName = """ & varProvGrp & _
""" and PROV_SUB_GRP_NAME = """ & varProvsubgrp & """"
rs.Open strsql, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
If Not rs.EOF Then
get_Issues = rs!SumOfCT
Else
get_Issues = 0
End If
rs.Close
Set rs = Nothing
End Function
If I run the report I get an error in the rs.open statment above stating no value given for one or more required parameters. The query is not that complicated and both parameters are provided what's missing?
Public Function get_Issues(ByRef varProvGrp As String, varProvsubgrp As String) As Long
Dim strsql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
strsql = "SELECT Sum([CT]) AS SumOfCT " & _
"FROM [0008_PCP Transfers by Group - with MM] " & _
"Where ProvGroupName = """ & varProvGrp & _
""" and PROV_SUB_GRP_NAME = """ & varProvsubgrp & """"
rs.Open strsql, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
If Not rs.EOF Then
get_Issues = rs!SumOfCT
Else
get_Issues = 0
End If
rs.Close
Set rs = Nothing
End Function
If I run the report I get an error in the rs.open statment above stating no value given for one or more required parameters. The query is not that complicated and both parameters are provided what's missing?