Sub testDaoCache()
Const cCacheSize As Integer = 1200 'The value of the CacheSize property must be between 5 and 1200, but not greater than available memory will allow. A typical value is 100. A setting of 0 turns off caching.
Dim rs As DAO.Recordset
Dim lngStart As Long
Dim lngCount As Long
Set rs = CurrentDb.OpenRecordset("Sales_SalesOrderDetail", dbOpenDynaset, dbSeeChanges) 'Sales_SalesOrderDetail: 120K records.
'Caching recordset
With rs
.CacheStart = .Bookmark
.CacheSize = cCacheSize
.FillCache 'ODBC linked tables only.
lngStart = GetTickCount()
.MoveFirst
While Not lngCount > 10000
.MoveNext
lngCount = lngCount + 1
If lngCount Mod cCacheSize = 0 Then
.CacheStart = .Bookmark
.FillCache
End If
Wend
Debug.Print Time$, "Cache Size: " & cCacheSize, "Delta time: " & GetTickCount() - lngStart & " msec."
End With
End Sub