execl access类型不对怎么回事?
类型不对怎么回事?Private Sub CommandButton2_Click()
Dim pf As String
pf = InputBox("请输入数据库所在盘符:")
MsgBox ("你确认盘符" & pf & " ")
Sheets("Sheet2").Select
If a1 = "" Then
Sheets("sheet2").Range("A1:i20000").Select
Selection.ClearContents
'Selection.QueryTable.Delete
Sheets("sheet2").Range("i20000").Select
Sheets("sheet2").Range("A1").Select
Else
Sheets("sheet2").Range("A1:i20000").Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets("sheet2").Range("i20000").Select
Sheets("sheet2").Range("A1").Select
End If
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=" & pf & ":\AAA\JXBMXT.mdb;DefaultDir=" & pf & ":\AAA;DriverId=25;FIL=MS Access;MaxBufferSize=2048ageTimeou" _
), Array("t=5;")), Destination:=Sheets("sheet2").Range("A1"))
[bo]从这句开始 .CommandText = Array( _
"SELECT drv_temp_mid.编号, drv_temp_mid.XM, drv_temp_mid.XB, drv_temp_mid.SFZMHM, drv_temp_mid.ZKCX, drv_temp_mid.DJZSXXDZ,drv_temp_mid.备注,drv_temp_mid.LXDH, drv_temp_mid.LXZSYZBM, drv_temp_mid.LXZSXXDZ, drv_temp_mid.SG, drv_temp_mid.ZSL, drv_temp_mid.YSL, drv_temp_mid.TL" & Chr(13) & "" & Chr(10) & "FROM `" & pf & ":\aaa\JXBMXT`.drv_temp_mid drv_temp_mid")
到这段说类型不对,不知为何?[/bo]
.Name = "查询来自 MS Access Database"
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
Sheets("FFF").Select
End Sub