View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Updating Querytables and Pivottables

Sounds like you are executing these refresh commands in code and you have
backgroundquery set to True. Set backgroundquery to False and it should
solve your problem.

--
Regards,
Tom Ogilvy

"Buck" wrote in message
oups.com...
I have a workbook with three worksheets. Sheets 1 and 2 contain
pivot-tables whose source is a query-table in sheet 3 whose source is a
local Access mdb table. The workbook also has a module that contains
two procedures. 'Sub UpdateQT' uses 'querytable.refresh' to update
sheet 3 and 'Sub UpdatePT' uses pivottable.refreshtable to update
sheets 1 and 2.

Initially the query-table was linked to an Access table that the
following:
Field1, Field2
A 1
B 2

I added data to the table:
Field1, Field2
A 1
B 2
E 3

Then I first ran querytable.refresh on sheet 3 and followed by
pivottable.refreshtable on sheets 1 and 2. The new third row of data
(E-1) appeared in the query-table but not in the pivot-tables.

Then I deleted the third row of data from the access table leaving only
the two rows with A-1 and B-2. I first ran querytable.refresh on sheet
3 and followed by pivottable.refreshtable on sheets 1 and 2. The
query-table then contained A-1 and B-2, but the pivot-table contained
A-1, B-2, E-3; the refreshtable method is always one data set behind.

Without any changes to the source data, running the two procedures a
second time gets the two pivot-tables back in sync with the
query-table. All three contain A-1, B-2.

Since .refreshtable is always one data set behind I thought running
.PivotCache.Refresh and the .refreshtable would get the pivot and query
tables in sync but it didn't.

Anyone have any ideas on how to get the update process to work in one
pass rather than two?

Buck