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: 4
Default Error on refresh backgroundquery - help please

I am trying to run an ODBC query to an informix database. I have done this
is previous organisations without any trouble, but for some reason I am now
getting errors.

Run-time error '1004'
Application-defined or object-defined error

And for the life of me I cant work it out.

CODE:

Sub CreateQT()

Dim ConnectStr As String
Dim SqlStr As String
Dim Statsqry As QueryTable

ConnectStr =
"ODBC;DSN=CMS;UID=xxx;PWD=xxx;Database=store7;Fetc hBufferSize=30;Host=xx.x.xx.xx;NoLoginBox=No;Optio ns=;Protocol=TCP/IP;ReadOnly=Yes;ServerOptions=;ServerType=Informix 2000"

TodayStr = Format(Date, "yyyy-mm-dd")
YestStr = Format(Date - 1, "yyyy-mm-dd")

SqlStr = "SELECT hsplit.row_date, synonyms.item_name,
Sum(hsplit.acdcalls), Sum(hsplit.acceptable), Sum(hsplit.abncalls),
Sum(hsplit.abntime), Sum(hsplit.holdcalls), Sum(hsplit.holdtime),
Max(hsplit.maxocwtime), Sum(hsplit.acdtime), Sum(hsplit.acwtime),
Sum(hsplit.transferred), Sum(hsplit.anstime), Sum(hsplit.callsoffered)" &
Chr(13) & "" & Chr(10) & "FROM root.hsplit hsplit, root.synonyms synonyms" &
Chr(13) & "" & Chr(10) & "WHERE synonyms.value = hsplit.split AND
((synonyms.item_type='split') AND (hsplit.row_date={d '" & YestStr & "'}) AND
(hsplit.split=22 And hsplit.split<=31))" & Chr(13) & "" & Chr(10) & "GROUP
BY hsplit.row_date, synonyms.item_name, hsplit.split" & Chr(13) & "" &
Chr(10) & "ORDER BY hsplit.split"

Set Statsqry = Sheets(1).QueryTables.Add(Connection:=ConnectStr,
Destination:=Range("A1"))
With Statsqry
.CommandText = SqlStr
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

End Sub

Any assistance with this would be much appreciated. Thanks

Richard
 
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
Refresh produces #N/A error RhysPieces Links and Linking in Excel 1 July 11th 07 07:42 PM
Problems with .Refresh BackgroundQuery:=False dmplacebo Excel Worksheet Functions 0 July 11th 05 12:39 PM
Web query .Refresh BackgroundQuery:=False problem Jim[_55_] Excel Programming 1 January 26th 05 04:08 PM
Refresh BackgroundQuery problem when migrating to Excel XP Doron Hadar Excel Programming 1 November 4th 04 10:10 PM
Excel does not close from VB!! (when i refresh Refresh query with BackgroundQuery:=False) Anant[_2_] Excel Programming 1 August 6th 03 04:22 AM


All times are GMT +1. The time now is 10:27 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"