View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sharlene England Sharlene England is offline
external usenet poster
 
Posts: 12
Default 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.