Parameter query

E

Elsworth

I have one parameter query (8 parameters). I have a function which one
returns number of filtered records. What should i do to get that
filtered records not a their number. Below is that function.

Function OpenParamQuery(QryName, ParamArray ParamArgs() As Variant) As Long

Dim db As Database
Dim QryDef As QueryDef
Dim intI As Integer
Dim rs As Recordset
Dim rsCount As Long

On Error GoTo OpenParamQuery_Error

Set db = CurrentDb()
Set QryDef = db.QueryDefs(QryName)

For intI = 0 To UBound(ParamArgs())
QryDef.Parameters(intI) = ParamArgs(intI)
Next

Set rs = QryDef.OpenRecordset()
OpenParamQuery = rs.RecordCount

OpenParamQuery_Exit:
Set QryDef = Nothing
rs.Close
Exit Function

OpenParamQuery_Error:
OpenParamQuery = 0
GoTo OpenParamQuery_Exit

End Function

TIA

Elsworth
 
Top