View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
SeeKY SeeKY is offline
external usenet poster
 
Posts: 4
Default Refreshing a database query

Hi all ,
i am not too good at vba but i have a command button that activates to
refresh a database query frm other worksheets then refresh a pivot table(data
is from query) follow by doing a Calculate

The database query always encounter 1 problem
My database query cant refresh after i press it for second time.
its like the table is copied onto the sheet and cannot be refresh.
Anyone can highlight me the problemes?

thanks
below my code for the command button.

Private Sub RefData_Click()
Sheets("BalancePO").Activate
Selection.QueryTable.Refresh BackgroundQuery:=False

Sheets("POTable").Activate
Set pvtTable = Worksheets("POTable").Range("A1").PivotTable
pvtTable.SourceData = "Database"
pvtTable.RefreshTable

Sheets("EL2 Summary").Activate
Range("C19").Select
Application.MaxChange = 0.001
ActiveWorkbook.PrecisionAsDisplayed = False
Calculate
Calculate
End Sub