Pull data Access to Excel Pivot Table using an ADODB Connection

Harry Flashman

Active Member
Joined
May 1, 2011
Messages
361
I have some code that successfully pulls data from Access and puts it into a pivot table. I have been looking around at similar routines and I have found some that use a PivotCache property that I have thus far not used, namely .OptimizeCache.

For example:
Code:
Set ptCache = wbBook.PivotCaches.Add(SourceType:=xlExternal)
     
     'Add the Recordset as the source to the pivotcache.
    With ptCache
        .OptimizeCache = True
        Set .Recordset = rst
    End With

For the full routine see this link to a post on Ozgrid: Populate pivottables using ADO

The full routine creates fetches the data from Access, creates the pivot table and then populates the Pivot Table (or rather the PivotCache).

When I run this code, however I get an error, Application defined or object defined error, right on the line .OptimizeCache = True

Why might this be?

For a look at a routine that is a bit closer to the one I intend to modify using this OptimizeCache property see this thread I posted a little while back:

http://www.mrexcel.com/forum/excel-...-access-excel-pivot-table-speed-up-query.html

I have no trouble use an ADODB Connection otherwise, and to be honest I am not completely sure what .OptimizeCache actually does, but it sounds like it might either improve pivot table performance, or make it easier and quicker to refresh the pivot table when new data arrives.

Is anyone familar with this PivotCache property, .OptimizeCache?

Is it worth using? Where might I be going wrong.

I am using Excel 2013 (64 bit) Access 2010 (64 bit). As I mentioned I am currently successfully fetching data using an ADODB Connection, but this one point I am getting an error message.

I am going to hazard a guess that my issue might be something to do with using a 64 bit version of Office (simply because this seems to be the most frequent cause of problems). But I would like to know for sure.
 
Last edited:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,215,465
Messages
6,124,975
Members
449,200
Latest member
Jamil ahmed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top