OK, I give up. Tired of trying and hitting the wall.
I have this insert query.
I have a function that returns the exact same sql as qrySentInquiries_Orders.
Debug.Print CreateSql
shows the following.
Now my question:
Is it possible to use this function in the insert into query above (instead of the saved query?)
Something like :
I have this insert query.
SQL:
INSERT INTO
tblPKs (PK, UserFK)
SELECT
InquiryPK, 1
FROM
qrySentInquiries_Orders
WHERE
InquiredBy=1 AND ReplyReceivedOn IS NULL
I have a function that returns the exact same sql as qrySentInquiries_Orders.
Debug.Print CreateSql
shows the following.
SQL:
SELECT
s.InquiryPK,
s.InquiredOn,
s.InquiredBy,
s.InquiryOrderNo,
s.InquiredFor,
s.ReplyReceivedOn,
o.SetName,
o.OrderDrNoChanges,
p.DrawingNo,
p.DrawingName,
u.UserName
FROM
(tblSentInquiries_Orders AS s
INNER JOIN (tblOrders AS o
INNER JOIN tblProducts AS p
ON o.OrderProductFK = p.ProductPK)
ON s.InquiryOrderNo = o.OrderNo)
INNER JOIN tblUsers AS u
ON s.InquiredBy = u.UserPK
WHERE
o.SetName IS NULL;
Now my question:
Is it possible to use this function in the insert into query above (instead of the saved query?)
Something like :
SQL:
sql = "INSERT INTO tblPKs (PK, UserFK) "
sql = sql & "SELECT InquiryPK, 1 "
sql = sql & "FROM " & CreateSql & " "
sql = sql & "WHERE InquiredBy=1 AND ReplyReceivedOn IS NULL"
db.Execute sql, dbSeeChanges