MS Query/Pivot Table Reference Change

ryan33

New Member
Joined
Apr 22, 2008
Messages
4
Situation: I am using an Access db as the source of information for a pivot table. Currently the db is on an external drive, but I would like to move it to a local drive so I made a copy of the db. Going through the Pivot Table Wizard, I wanted to change where my pivot table looks to access the db. Once in MS Query, I go through the SQL dialog button and change the file path. Once I go back into Excel/Pivot Table, it seems to refresh the data. When I actually remove the db from the external drive and refresh the pivot tables, I get the error message: 'Could not find file: '[External Drive]:\[filename].mdb.'' I noticed that when I do refresh the table with the db on the external drive and a copy on the local drive, it accesses both files.

Question: If I change the file path in the SQL dialog, is there another place I need to make the change?

Any help would be appreciated.

Thanks,

Ryan
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
There are two things - the connection and the SQL.

You have changed the SQL, so need still to change the connection.

Manual way as connection property is read/write. Activate the worksheet with the PT. Go to VBEditor (ALT-F11). In the immediate window (CTRL-G) type in
Code:
? activesheet.pivottables(1).pivotcache.connection
Now edit the string to suit the new file location and set/write it with a line like
Code:
activesheet.pivottables(1).pivotcache.connection = "your updated string"
(This can be done by editing within the immediate window, BTW. But do it how you like.)

Now refresh the PT.

HTH, Fazza
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

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