0
我有一個腳本沒有在我的系統上運行。我不是這方面的專家,製作劇本的人已經不在這個組織了。運行時錯誤'1004 :,一般的ODBC錯誤
任何這方面的援助將不勝感激。
做調試後,高亮顯示的申請是「.Refresh BackgroundQuery:=False
」
下面是腳本: -
Sub Run_Customs_Report()
'
' Macro4 Macro
'
'
Sheets("Customs_Report").Select
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array(_
"ODBC;DSN=GOMS_MEM;UID=OD173;PWD=Adbu765$;DBQ=MDCGOMP.WORLD;DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;BTD=F;BNF=F;BAM" _
), Array(_
"=IfAllSuccessful;NUM=NLS;DPM=F;MTS=T;MDI=F;CSR=F;FWC=F;FBS=64000;TLO=O;MLD=0;ODA=F;STE=F;TSZ=8192;" _
)), Destination:=Range("$A$1")).QueryTable
.CommandText = Array(_
"SELECT TO_CHAR (D.PRINT_PART_NO) AS ""Print Part"",A.CATALOG_DESC AS ""Descripcion"",B.COUNTRY_OF_ORIGIN AS ""Country"",B" _
, _
".Packing_list_no AS ""Packing List"",TO_CHAR (A.order_no) AS ""Order"", A.Customer_PO_NO AS ""PO"", ROUND(A.Unit_Price) AS ""Unit" _
, _
" Price"", SUM (B.QTY_SHIPPED) AS ""Qty"", ROUND(SUM (A.unit_Price * B.QTY_SHIPPED)) AS ""Ext Total"", TO_CHAR (B.INVOICE_NO) AS" _
, _
" ""Manifest"", TO_CHAR(B.INVOICE_DATE) AS ""Date"", C.note_text AS ""GOMS Ref"", TO_CHAR (B.TRACKING_NO) AS ""Tracking No"", TO_CHAR" _
, _
" (A.SHIP_TO_ABBR) AS ""Ship To Location"" FROM oeorder_detail A INNER JOIN oeorder_shipping B ON A.part_no = B.part_n" _
, _
"o AND A.order_no = B.order_no AND A.line_no = B.line_no INNER JOIN OECUSTOMER_ORDER_NOTES C ON A.order_no = C.order" _
, _
"_no INNER JOIN PART_DESCRIPTION D ON A.part_no = D.part_no AND A.SHIP_TO_ABBR IN ('54827','54734','55945','56169','" _
, _
"55897','56086') AND (TRUNC (SYSDATE) - TRUNC (INVOICE_DATE)) = '1' AND B.tracking_no IS NOT NULL AND note_no = '1' " _
, _
"AND LINE_NO is null GROUP BY D.PRINT_PART_NO,A.CATALOG_DESC,B.COUNTRY_OF_ORIGIN,B.Packing_list_no,A.order_no," _
, _
"Customer_PO_NO,A.Unit_Price,B.INVOICE_NO,B.INVOICE_DATE,C.note_text, B.TRACKING_NO, A.SHIP_TO_ABBR ORDER BY A.Ship_" _
, "To_Abbr, B.INVOICE_NO")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_ExternalData_1"
.Refresh BackgroundQuery = False
end with
end sub
[Refresh BackgroundQuery:= False |幫助需要?](https://stackoverflow.com/questions/33428059/refresh-backgroundquery-false-help-需要) – MikeyM