| 
    
     |  | 次のようなデータベースクエリーを新規で作成し、「dbAitem」の値を変化させてデータを抽出したいのですが、最終行の「Refresh BackgroundQuery:=False」でエラーが出ます。 対処方法をご教授ください。
 
 
 Dim dbAitem As String
 
 dbAitem = "岡山工業株式会社"
 db1 = "ODBC;DSN=Excel Files;DBQ=C:\損益データ.xls;DefaultDir=C:\Data;DriverId=790;MaxBufferSize=2048;PageTime"
 db2 = "SELECT `DB$`.コード, `DB$`.得意先名, `DB$`.年月日, `DB$`.売上対策"
 db3 = "FROM `C:\損益データ`.`DB$` `DB$`"
 db4 = "WHERE (`DB$`.得意先名=" & dbAitem & ") AND (`DB$`.売上対策<>'"
 
 
 With ActiveSheet.QueryTables.Add(Connection:=Array(Array(db1), Array("out=5;")), Destination:=Range("A1"))
 .CommandText = Array( _
 db2 & Chr(13) & "" & Chr(10) & db3 & Chr(13) & "" & Chr(10) & db4, " ')")
 .Name = "Excel Files からのクエリ"
 .FieldNames = True
 .RowNumbers = False
 .FillAdjacentFormulas = False
 .PreserveFormatting = True
 .RefreshOnFileOpen = False
 .BackgroundQuery = True
 .RefreshStyle = xlInsertDeleteCells
 .SavePassword = True
 .SaveData = True
 .AdjustColumnWidth = True
 .RefreshPeriod = 0
 .PreserveColumnInfo = True
 .Refresh BackgroundQuery:=False
 End With
 
 
 |  |