OK, I put the information you gave me into a string and now I get an error
that says "Query input must contain one table or query....here's the
code...when I had code the path it works...so I don't knoiw what I'm doing
wrong.
Function MakeOpenOrdersTable()
Dim db As Database
Dim strsql As String
Dim strtmp As String
Set db = CurrentDb
strtmp = Mid(CurrentDb.TableDefs("TWDXRF").Connect, 11)
MsgBox (strtmp) '*****************This looks right******************
strsql = "SELECT TWDHPH.PHENDT, IIf(Not
IsNull([PHENDT]),DateSerial(Left([PHENDT],4),Mid([PHENDT],5,2)," _
& "Right([PHENDT],2)),0) AS ActualShipDate, IIf(IsNull([ActualShipDate])
Or [ActualShipDate]>=Now()-60,-1,0) " _
& "AS OpenOrd, tblCustomerMaster.CCUST, tblCustomerMaster.CNME,
TWDXRF.XCPO, TWDHPO.PPROD, TWDHPO.PVEND, " _
& "TWDXRF.XTPO, TWDHPO.PLINE, TWDHPO.PQORD, TWDLIN.LSHQTY, TWDECH.HEDTE,
TWDHPO.ConfirmedShpDate, " _
& "TWDHPO.ScheduledDate, TWDXRF.XCORD, TWDXRF.XCUST, TWDXRF.XTVND,
tblVendorMaster.VNDNAM, TWDIIM.IDESC, " _
& "tblBuyer.DESC AS BUYER, TWDLIN.LBOL, TWDLIN.LESTDP,
tblCustomerMaster.CREF02 AS PM INTO tblTmpQuery3 " _
& "IN " & strtmp & " " & vbCrLf _
& "FROM (((((((TWDXRF LEFT JOIN TWDHPO ON TWDXRF.XTPO = TWDHPO.PORD)
LEFT JOIN tblCustomerMaster ON " _
& "TWDXRF.XCUST = tblCustomerMaster.CCUST) LEFT JOIN tblVendorMaster ON
TWDXRF.XTVND = tblVendorMaster.VENDOR) " _
& "LEFT JOIN TWDIIM ON TWDHPO.PPROD = TWDIIM.IPROD) LEFT JOIN tblBuyer
ON TWDIIM.IBUYC = tblBuyer.IPURC) " _
& "LEFT JOIN TWDLIN ON (TWDHPO.PORD = TWDLIN.LTWPO) AND (TWDHPO.PLINE =
TWDLIN.LTWPOL)) " _
& "LEFT JOIN TWDHPH ON TWDHPO.PORD = TWDHPH.PHORD) LEFT JOIN TWDECH ON
TWDXRF.XCORD = TWDECH.HORD " _
& "ORDER BY TWDHPH.PHENDT DESC , IIf(Not
IsNull([PHENDT]),DateSerial(Left([PHENDT],4),Mid([PHENDT],5,2)," _
& "Right([PHENDT],2)),0), tblCustomerMaster.CNME, TWDXRF.XCPO,
TWDHPO.PPROD;"
'This was the line the string replaced:
'& "IN 'D:\Documents and Settings\Administrator\My Documents\Curent
Docs\Trans\Trans_Data.mdb' " _
'***************This works with it hard-coded******************
MsgBox (strsql) '*****************This look right******************
DoCmd.RunSQL strsql
set db = nothing
End Function
The path looks right from the string when I put it in a msgbox and the sql
statement looks right from the msgbox.
Any ideas?
Thanks for your help.
Douglas J Steele said:
I assume you meant that your example doesn't work... Try:
strPathToBack = Mid(CurrentDb().TableDefs("NameOfSomeLinkedTable").Connect,
11)
make