I happened upon the following code for using ADO/SQL to extract a record count for Access Queries...
Is it possible to revise this to extract the SUM of a field in a query? Or do I need to go another route?
Code:
Private Function Record_Count(sSQL As String)
Set cnn = New ADODB.Connection
With cnn
.CommandTimeout = 0
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & FolderName & TARGET_DB
.Open
End With
Set cmd = New ADODB.Command
With cmd
.CommandTimeout = 0
.CommandType = adCmdText
.CommandText = sSQL
.ActiveConnection = cnn
End With
Set rst = New ADODB.Recordset
rst.Open cmd, , adOpenStatic, adLockReadOnly
Record_Count = rst.RecordCount
rst.Close
cnn.Close
Set cnn = Nothing
Set cmd = Nothing
Set rst = Nothing
End Function