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: 3
Default Query Tables

I am trying to run a program that accesses one of our
database systems and creates a query table. I keep
getting the following error message "Run-Time Error 1004:
The operation cannot be done because the data is
refreshing in the background." If anyone has any
suggestions that would be great. My code is as follows:


Sub LFQuery()
' LFQuery Macro
' Macro recorded 6/21/2004 by Randy Kreider and Dale D.
Marques
' Declaring and Setting Variables
var1 = CStr(Worksheets("Customer").Range("F2").Value)
var2 = CStr(Worksheets("Customer").Range("F4").Value)
Worksheets("Customer").Unprotect
Range("A7:L18000").ClearContents
' Import Query Table
With ActiveSheet.QueryTables().Add(Connection:= _
"ODBC;DRIVER={Microsoft ODBC for
Oracle};UID=;PWD=;SERVER=cdapd;", _
Destination:=Worksheets("Customer").Range("A7"))
.Sql = " SELECT CDM_LOCATIONS.OP_CENTER,
CDM_ESSR.METER_READ_DT, CDM_BILL_ACCOUNTS.BILL_ACCT_NUM,
CDM_BILL_ACCOUNTS.CUSTOMER_NAME,
CDM_TARIFF_SCHEDULES.TARIFF_RATE_DESIGNATION,
CDM_ESSR.REV_YR_MO, SUM(CDM_ESSR.KWH), SUM
(CDM_ESSR.MAXIMUM_DEMAND), SUM(CDM_ESSR.BILLED_DEMAND), SUM
(CDM_ESSR.COUNT_AS_BILL), SUM(CDM_ESSR.BILLING_DAYS)" & _
" FROM CDADM.CDM_LOCATIONS CDM_LOCATIONS,
CDADM.CDM_ESSR CDM_ESSR, CDADM.CDM_BILL_ACCOUNTS
CDM_BILL_ACCOUNTS, CDADM.CDM_SERVICE_SUPPLIERS
CDM_SERVICE_SUPPLIERS, CDADM.CDM_TARIFF_SCHEDULES
CDM_TARIFF_SCHEDULES " & _
" WHERE (CDM_LOCATIONS.LOCATION_GK_PK =
CDM_ESSR.LOCATION_FK) AND
(CDM_BILL_ACCOUNTS.BILL_ACCT_GK_PK =
CDM_ESSR.BILL_ACCT_FK ) AND (
CDM_TARIFF_SCHEDULES.TARIFF_SCHED_GK_PK =
CDM_ESSR.TARIFF_SCHED_FK) AND (CDM_ESSR.METER_READ_DT
BETWEEN TO_DATE('" & var1 & "','YYYYMMDD') AND TO_DATE('"
& var2 & "','YYYYMMDD')) AND
(CDM_TARIFF_SCHEDULES.TARIFF_RATE_DESIGNATION IN
(( 'LP6 ')) ) AND
(CDM_SERVICE_SUPPLIERS.SERVICE_SUPPLIER_GK_PK =
CDM_BILL_ACCOUNTS.SERVICE_SUPPLIER_FK)" & _
" GROUP BY CDM_LOCATIONS.OP_CENTER,
CDM_ESSR.METER_READ_DT, CDM_BILL_ACCOUNTS.BILL_ACCT_NUM,
CDM_BILL_ACCOUNTS.CUSTOMER_NAME,
CDM_TARIFF_SCHEDULES.TARIFF_RATE_DESIGNATION,
CDM_ESSR.REV_YR_MO"
' Query Table Formatting
.FieldNames = False
.RefreshStyle = xlOverwriteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = False
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery = False
.SavePassword = True
.SaveData = True
End With
Worksheets("Customer").Protect DrawingObjects = True,
contents = True, Scenarios = True
End Sub

 
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
MS Query - Joining two tables.... Marc T Excel Discussion (Misc queries) 1 September 10th 09 04:18 PM
Web query doesn't allow me to select tables cmarcus Excel Discussion (Misc queries) 0 August 12th 09 09:34 PM
MS Query No visible tables ChrisP Excel Discussion (Misc queries) 3 September 6th 05 08:51 PM
Web Query from multiple tables jjbf22 Excel Discussion (Misc queries) 0 July 29th 05 03:28 PM
Two Excel tables in MS Query Jamshed Excel Discussion (Misc queries) 0 June 24th 05 12:33 PM


All times are GMT +1. The time now is 12:41 PM.

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"