I would like to load the results of a sql query into an array. I am utilizing the following approach which is terribly inefficient:
Code:
'Calculate number of placements events for selected Client
strSQL = "SELECT COUNT(*) FROM dbo_VPlacements WHERE Customer = '" & Client & "'"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
NCount = rs.Fields(0)
ReDim PlacementArray(1 To NCount)
'Load placement numbers into array
For xx = 1 To NCount
strSQL = "SELECT Top 1 PlacementCount FROM (SELECT Top " & xx & " PlacementCount, PlacementDate FROM (SELECT PlacementCount, PlacementDate FROM dbo_VPlacements WHERE PlacementDate = #" & PriorDay & "# ORDER BY PlacementDate ASC)) ORDER BY PlacementDate"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
PlacementArray(xx) = rs.Fields("PlacementCount")
Next xx
I get a syntax error when I just try to set the array equal to the selected recordset. Any ideas?