ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Query Refresh Error (https://www.excelbanter.com/excel-programming/391753-query-refresh-error.html)

Gibu John George[_2_]

Query Refresh Error
 
Hi,

I am using Microsoft Query to guery an excel file and then get the queried
data into another excel sheet. But each time I try the same VBA code , with
the query conditions changed, for another excel it returns an error "Run-Time
error "1004" Application definition or Object definition error " when it
tries to execute ".Refresh BackgroundQuery:=False"

But when I record a new query macro specific to the new excel sheet it works
fine.

anybody with any resolutions/suggestion?

mail :

VBA CODE:

Sheets("Sheet3").Select
With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _
"ODBC;DSN=Excel Files;DBQ=C:\Program Files\Apache Software
Foundation\Tomcat 6.0\webapps\Web_Matrics\project_data\RP\ASTC\" &
current_week & "\RP_ATSC" _
), Array( _
"_" & current_week_date_NXP & "_" & current_time &
".xls;DefaultDir=C:\Program Files\Apache Software Foundation\Tomcat
6.0\webapps\Web_Matrics\project_data\RP\ASTC\" & current_week & ";" _
), Array("DriverId=790;MaxBufferSize=2048;PageTimeout =5;")),
Destination:= _
Range("A1"))
.CommandText = Array( _
"SELECT `DataSheet$`.`Request Type`, `DataSheet$`.`Sub System`,
`DataSheet$`.Status" & Chr(13) & "" & Chr(10) & "FROM `DataSheet$`
`DataSheet$`" & Chr(13) & "" & Chr(10) & "WHERE (`DataSheet$`.`Request
Type`='CR') AND (`DataSheet$`.`Resolved Week`= & current_week)" _
, _
"OR (`DataSheet$`.`Request Type`='CR') AND (`DataSheet$`.`Resolved
Wk`= & current_week)" _
)
.Name = "Query from Excel Files1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = False
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com