Hi All,
I've been using DCount to count records in an existing query, however I was finding this to bwe a very slow function and thought I could speed it up using ADO, my code is as below:
The problem is that this gives counts for tables but feeding it query names results in an error "No value given for one or more reuired parameters".
Please can anyone point me at a way of fixing this?
Thanks
I've been using DCount to count records in an existing query, however I was finding this to bwe a very slow function and thought I could speed it up using ADO, my code is as below:
Code:
Function GetRecordCount(TableName As String) As Long
Dim rs As New ADODB.Recordset
Dim ssql As String
Dim Result As Long
ssql = "Select Count(*) From " & TableName
rs.Open ssql, CurrentProject.Connection, adOpenStatic, adLockOptimistic
Result = rs.Fields(0).Value
rs.Close
Set rs = Nothing
GetRecordCount = Result
End Function
The problem is that this gives counts for tables but feeding it query names results in an error "No value given for one or more reuired parameters".
Please can anyone point me at a way of fixing this?
Thanks
Last edited: