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: 27
Default Pivot table not refreshing

I've created some code to change the database used in a PivotCache. (Based
on snippets found in this group.) Based on the MsgBox statement at the end,
it appears the database is changing, however a refresh of the table shows
the old data. Where am I going wrong? I'm finding it difficult to locate
good examples of changing SQL database.

Sub ChangeDatabase()
'Declare our variables.
Dim ptc As PivotCache, oldDB As String, newDB As String
Set ptc = ActiveCell.PivotTable.PivotCache

MsgBox "Connection: " & ptc.Connection ' Confirms the current settings

'Request the name of the old server/file name.
oldDB = InputBox("Input the name of the old database or file path as
listed in the Pivot Tables SQL string.")

'Request the name of the new server/file name.
newDB = InputBox("Input the name of the new database or file path which
you want the Pivot Table to point to.")

'Replace the ODBC information of whatever PivotTable is currently
active.

ptc.Connection = Application.Substitute(ptc.Connection, oldDB, newDB)
ptc.Refresh

MsgBox "Connection: " & ptc.Connection ' Shows new connection
information

End Sub


Thanks - John


 
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
Refreshing a pivot table Neville Bailey[_2_] Excel Discussion (Misc queries) 1 November 16th 08 05:47 PM
Pivot Table Refreshing Yuanhang Excel Discussion (Misc queries) 0 November 30th 07 10:43 PM
Pivot table refreshing Daniel Excel Discussion (Misc queries) 5 July 12th 07 05:02 PM
When refreshing pivot tables my pivot table chart type changes hannah220507 Excel Discussion (Misc queries) 1 May 22nd 07 02:57 PM
Refreshing a pivot table Louise Excel Discussion (Misc queries) 2 May 23rd 05 01:40 PM


All times are GMT +1. The time now is 03:36 AM.

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"