Help with Append Query via VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the below string in VBA to generate the SQL for a select query.

I would like to change this so I can append this data to
tlbContractReviewControl. I have tried searching in the help guide but I cant
find anything. Can anyone help?

strSQL = "SELECT tblContracts.ContractID, tblContracts.SupplierID,
tblSuppliers.SupplierName, " & _
"tblContracts.ContractDescription, tblContracts.StartDate,
tblContracts.EndDate, tblContracts.NoticePeriod, " & _
"tblContracts.ReviewDate, tblContracts.FinancialCommitment,
tblContracts.ContractNotes, tblOwners.FirstName, " & _
"tblOwners.LastName, tblOwners.Email, tblCommodity.CommodityGroup,
tblPurchasingRoles.Email " & _
"FROM ((tblSuppliers LEFT JOIN tblCommodity ON
tblSuppliers.CommodityID = tblCommodity.CommodityID) " & _
"LEFT JOIN tblPurchasingRoles ON tblCommodity.StaffID =
tblPurchasingRoles.StaffID) " & _
"INNER JOIN (tblOwners RIGHT JOIN tblContracts ON tblOwners.OwnerID
= tblContracts.OwnerID) " & _
"ON tblSuppliers.SupplierID = tblContracts.SupplierID " & _
"WHERE " & strExpired & strCommodity & "
tblContracts.AnnulledContract Is Not Null;"
 
an append query i use.
INSERT INTO tempBOM ( ParentID, ParentIDName, ComponentID,
CompIDName, LevelCode, QPA, AcctvalAmt, EffStartDate,
EffStopDate )
SELECT DISTINCT dbo_PST.ParentItemID, IMA,ItemName,
PST.CompItemID, IMA_1ItemName, dIMA_1.LowLevelCode,
PST.QtyPerAssy, IMA_1.AcctValAmt, PST.ffStartDate,
PST.EffStopDate
FROM (PST INNER JOIN IMA ON PST.ParentItemID = IMA.temID)
INNER JOIN IMA AS IMA_1 ON PST.CompItemID = IMA_1.ItemID
WHERE (((PST.ParentItemID)= """ & [Forms]![frmBOMII]!
[txtParentId])& """ AND ((PST.EffStartDate)<=Now()) AND
((PST.EffStopDate)>Now() Or (PST.EffStopDate) Is Null));
 
Back
Top