PC Review


Reply
Thread Tools Rate Thread

Child pivot table's source breaking from parent pivot table

 
 
Michael Kucan
Guest
Posts: n/a
 
      1st Oct 2008
I have a workbook with several pivot tables. There is one parent pivot table
that is the source for all child pivot tables. When I manually refresh the
parent pivot table, all child pivot tables are automatically refreshed. This
works great.

The parent pivot table's source is an ODBC connection to our warehouse. I
have to modify the WHERE clause of the SQL statement daily to update the
parent pivot table.

When I use code to alter the SQL of the parent table, all of the child
tables seem to break their source link from the parent, and continue to use
the old ODBC connection and SQL statement.

When I use code to try to repoint the child tables back to the parent, I get
an "Application-defined or object-defined error" error. Here is the snippet
I use to update the parent table (arySQL contains the SQL statement as a
one-dimensional array):

xlWS_Daily.PivotTables("DailyPivotTable").PivotTableWizard _
SourceType:=xlExternal _
,Connection:="ODBC;DSN=;UID=;;DATABASE=;ACCOUNT=;" _
,SourceData:=arySQL

I use the sparse Connection property, so that the client is prompted for the
ODBC connection every time.

Here is how I'm trying to re-point one of the child tables. This is where I
am getting the error:

xlWS_Monthly.PivotTables("MonthlyPivotTable").PivotTableWizard _
SourceType:=xlPivotTable _
,SourceData:="DailyPivotTable"

I recorded a macro of me manually re-linking the tables, and the above
statement was what it grabbed. However, when I'm running the script, it
throws the error.

I know I'm doingn something wrong, but I can't figure it out. Any ideas?

Thanks in advance for any help I can get.

--
Thanks,

Michael Kucan
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot Table - Parent to Child Data Brennan Microsoft Excel Misc 1 24th Sep 2008 05:23 AM
Code that will rerun or refresh a pivot table (after new data ispasted into the original Pivot Table's Source Range) Mike C Microsoft Excel Programming 3 15th Feb 2008 06:22 AM
OfficeXP "Cannot open pivot table source file" when refreshing pivot table Luc Alquier Microsoft Excel Programming 2 9th Dec 2003 11:11 PM
Pivot tables, linking to a named range as a source to a pivot table Karen Microsoft Excel Misc 1 18th Oct 2003 01:45 PM
Help required with setting up a pivot table with the source on sheet1 to have the pivot table created on sheet called "report" Diana Microsoft Excel Programming 0 21st Aug 2003 10:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:55 PM.