Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Pivot tables not refreshing after data source update

I'm trying to two refresh pivot tables on a worksheet that are bound
to the same data. I find that it takes two successive calls in order
to get this to work. However, a "Refresh" button placed on the page
that calls basically the same code works perfectly when clicked only
one time. Below is the code to change the datasource query and
refresh the pivot tables when the user changes one of the inputs on
the page:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Trapper

'Reset command text and requery
If (Target.Address = Me.Range("StartDate").Address Or
Target.Address = Me.Range("EndDate").Address) Then
With ActiveWorkbook.Connections("srv1658
JumboRolls").OLEDBConnection
.CommandText = "My SELECT statement"
.Refresh
End With

For Each t In Worksheets("Analysis").PivotTables
t.PivotCache.Refresh
Next
End If
Exit Sub
Trapper:
'MsgBox Err.Description
Exit Sub

End Sub

Here is the code called on a button click that works just fine

Sub RefreshPivotTables()
For Each t In Worksheets("Analysis").PivotTables
t.PivotCache.Refresh
Next
End Sub

Does anyone have any idea why the first block of code would not
properly refresh the Pivot tables? It seems like a caching issue and
perhaps I don't understand the cache well enough.

Bill
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Pivot tables not refreshing after data source update

The resolution to this was to add

..BackgroundQuery = False

to the OLEDBConnection just before the call to Refresh. Thank you to
Bill Manville and Jan Karel Pieterse in the Compuserve Office forum
for the suggestion.

Bill

Reply
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
Pivot tables - Editing the data source shared by multiple pivot ta sankat Excel Discussion (Misc queries) 1 April 22nd 10 03:05 PM
Programmatically refreshing a data source for a pivot table (olap) Ant Excel Programming 0 April 10th 08 02:40 PM
Loosing formatting when refreshing data in Pivot tables Excel2003 BAS Charts and Charting in Excel 0 August 29th 07 11:04 AM
Pivot Table data source "data source contains no visible tables" Jane Excel Worksheet Functions 0 September 29th 05 08:28 PM
Pivot Tables - Refreshing with data??..... MrAlMackay Excel Programming 2 September 9th 03 08:47 PM


All times are GMT +1. The time now is 07:26 PM.

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

About Us

"It's about Microsoft Excel"