ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   QueryTables command (https://www.excelbanter.com/excel-programming/349534-querytables-command.html)

Sharlene England

QueryTables command
 
The following works properly, BUT when I add a WHERE clause to my
..commandtext I get an error 400.

IF I REPLACE THE .CommandText line with this it doesnt work
.CommandText = Array("SELECT CUSTCODE, PROJ_DESCR, PO_NUMBER, DATE,
PROJMAN, CUSTFORCD FROM `k:\home\sharlene`\job_no.dbf WHERE(JOB_NO=" &
Worksheets("Creation").Range("B3").Value & ")"

What am I doing wrong?


With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _
"ODBC;CollatingSequence=ASCII;DBQ=K:\home\sharlene ;DefaultDir=K:\home\sharlene;Deleted=1;Driver={Mic rosoft
dBase Driver (" _
), Array( _
"*.dbf)};DriverId=533;FIL=dBase
5.0;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=6 00;SafeTransactions=0;Statistics=0;Threads=3;U"
_
), Array("serCommitSync=Yes;")), Destination:=Range("B27"))
.CommandText = Array("SELECT CUSTCODE, PROJ_DESCR, PO_NUMBER, DATE,
PROJMAN, CUSTFORCD FROM `k:\home\sharlene`\job_no.dbf ") <<THIS
LINE WORKS AS IS
.Name = "realjob"
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlOverwriteCells
.AdjustColumnWidth = False
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

Thanks.




All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com