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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top