When i click on Debug, VB opens and it shows:
Object = General
Procedure = Get_program_dates
and highlighted in Yellow is: .Refresh BackgroundQuery:=False
I have searched the internet for the error 1004 and found many solutions that dont work. The real strange thing is why it does not work on my machine, but on the guys next to me it does? We have checked that we have the same connections (Data Sources). Is this a problem with something else? Even the guy (not myself) who wrote the code can't figure out why it is not working. I found where someone said it might have to do with dates? But why does it work on his and not mine?
Here is the snippet of code:
Expand|Select|Wrap|Line Numbers
- With ActiveSheet.QueryTables.Add(Connection:= _
- "ODBC;DSN=ADW;UID=CurUser;APP=Microsoft Office 2003;WSID=CP040;DATABASE=DataWarehouse;Trusted_Connection=Yes" _
- , Destination:=Range("A1"))
- .CommandText = Array( _
- "SELECT DISTINCT STRAT_All_View.EvSDate" & Chr(13) & "" & Chr(10) & "FROM DataWarehouse.dbo.STRAT_All_View STRAT_All_View" & Chr(13) & "" & Chr(10) & "WHERE (STRAT_All_View.EvSDate>{ts '2005-03-01 00:00:00'})")
- '"SELECT DISTINCT STRAT_All_View.EvSDate" & Chr(13) & "" & Chr(10) & "FROM DataWarehouse.dbo.STRAT_All_View STRAT_All_View" & Chr(13) & "" & Chr(10) & "ORDER BY STRAT_All_View.EvSDate DESC")
- .name = "Query from ADW"
- .FieldNames = True
- .RowNumbers = False
- .FillAdjacentFormulas = False
- .PreserveFormatting = True
- .RefreshOnFileOpen = False
- .BackgroundQuery = True
- .RefreshStyle = xlInsertDeleteCells
- .SavePassword = False
- .SaveData = True
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .PreserveColumnInfo = True
- .Refresh BackgroundQuery:=False