LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Setting CommandText property of PivotCache fails if cache has 1 PivotTable


I'm using Excel 2003

Ok, pivot table VBA studs, help me out he

Imagine you already have one pivot table report based on external data
say a query of an Access DB or perhaps of another Excel file (assume i
was created via the Wizard and Get Data...).

In VBA, the actual query is stored in the CommandText property of th
PivotCache, which is easily viewable by running the code (assumes onl
1 pivotcache for simplicity):

MsgBox ActiveWorkbook.PivotCaches(1).CommandText

You can also set the property in VBA by running the code:

ActiveWorkbook.PivotCaches(1).CommandText = "SELECT * FROM MyTabl
MyTable"

(WHERE clause omitted for simplicity) The query example above would b
the syntax for querying an external Excel database with a range calle
MyTable, and it works great - I can change the query in VBA, an
setting the CommandText property has the effect of refreshing th
cache.

So far so good. Now say I add another pivot table that uses the firs
PivotCache as its source (specifying as such in the Wizard), so tha
refreshing 2 reports only fires 1 query.

I can still run the code to get the sql:
MsgBox ActiveWorkbook.PivotCaches(1).CommandText

But I cannot run the code to set the sql:
ActiveWorkbook.PivotCaches(1).CommandText = "SELECT * FROM MyTabl
MyTable"

It causes a VBA error 1004. If I then remove the 2nd pivot table s
that the cache only has 1 report, it works fine again - I can set th
sql.

This seems clearly to me a bug in Excel. Any clever workarounds?
did see some threads about setting the property requiring a strin
array to get around a string size limitation, but that it is not th
problem, I think that was only in Excel 2000. At any rate in Exce
2003 I can set huge SQL strings, but I can't set anything if the cach
is shared.

Any clever ideas

--
ashortx
-----------------------------------------------------------------------
ashortxl's Profile: http://www.msusenet.com/member.php?userid=104
View this thread: http://www.msusenet.com/t-187041390

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disbale the shared PivotTable cache (Excel 2007) ANDI Excel Discussion (Misc queries) 1 December 1st 08 10:04 AM
PivotTable Object - Unable to get the name property Alan Excel Programming 0 December 6th 04 10:29 PM
VB .NET Excel Builtin Property Access fails Mark Nethercott Excel Programming 0 May 1st 04 04:48 PM
CommandText Property Dick Kusleika[_3_] Excel Programming 0 October 17th 03 11:04 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"