ma requête fonctionne lorsque j'effectue le code suivant:
Conn = "ODBC;"
Conn = Conn & "DSN=dBASE Files;"
Conn = Conn & "DefaultDir=Y:\PR;"
Conn = Conn & "DriverId=533;"
Conn = Conn & "MaxBufferSize=2048;"
Conn = Conn & "PageTimeout=5;"
With ActiveSheet.QueryTables.Add(Connection:=Conn, Destination:=Range("B6" ))
.CommandText = Array( _
"SELECT invitem.QUANTITY, invitem.STOCKCODE, code.DESCR, invitem.COST, invitem.NUMBER" & Chr(13) & "" & Chr(10) & "FROM `X:\03 ADMINISTRATION\Atrex\Data`\code.DBF code, `X:\03 ADMINISTRATION\Atrex\Data`\invitem.DBF invitem" & Chr(13) & "" & Chr(10) & "WHERE" _
, " (invitem.STOCKCODE Like code.stockcode) AND (invitem.NUMBER=1912)" )
.Name = "Lancer la requête à partir de dBASE Files"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
Par contre, quand j'essaye de formater un peu la requete, ça ne marche plus. Je ne comprends pas.
mysql = "SELECT invitem.QUANTITY, invitem.STOCKCODE, code.DESCR, invitem.COST, invitem.NUMBER FROM `X:\03 ADMINISTRATION\Atrex\Data`\code.DBF code, `X:\03 ADMINISTRATION\Atrex\Data`\invitem.DBF invitem WHERE (invitem.STOCKCODE Like code.stockcode) AND (invitem.NUMBER=1912)"
With ActiveSheet.QueryTables.Add(Connection:=Conn, Destination:=Range("B6" ))
.CommandText = Array(mysql)
.Name = "Lancer la requête à partir de dBASE Files"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With