Putting Action queries into code

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

Guest

I have a series of Append Queries that update a table. I've post an example
of the SQL below. Is it possible to store these append proceedures in code
instead of an append query object? And further, to have that code excute the
the used click's a command button on a form?

I know I can just have the button run the object or I could use macros,
suppose I'm trying to stem the literring of my Access program with query
objects where possible.

Thanks in advance,

Ben
 
Ha! You're right. I'll post it below... obviosly it's quite a bit messier.

INSERT INTO tbl_GLArchiveManualHold ( sCorpNum, sDeptNum, sCliNum, sCoNum,
sLoanNum, sAssignNum, sCollectNum, DBRAcctNum, DBRAcctNum, dtAsOf, Amount,
sAcctTyFlg )
SELECT DISTINCTROW "BHF" AS Corp, "DueDiligence" AS Dept, Projects.ClientID,
0 AS CO, 1 AS LN, "PJ" & [Time Card Hours].ProjectID AS PRJ, "TC" & [Time
Card Hours].TimeCardID & "-" & [FirstName] & " " & [lastname] AS TC, "AUF" AS
DBAccount, "DDR" AS CRAccount, Date() AS AsOf, Sum([Time Card
Hours]!BillableHours*[Time Card Hours]!BillingRate) AS [Total Time], "OpsMan"
AS flg
FROM (Employees INNER JOIN [Time Cards] ON Employees.EmployeeID = [Time
Cards].EmployeeID) INNER JOIN (Projects INNER JOIN [Time Card Hours] ON
Projects.ProjectID = [Time Card Hours].ProjectID) ON [Time Cards].TimeCardID
= [Time Card Hours].TimeCardID
WHERE ((([Time Cards].TimeCardID)=[Forms]![Time Cards]![TimeCardID]))
GROUP BY "BHF", "DueDiligence", Projects.ClientID, 0, 1, "PJ" & [Time Card
Hours].ProjectID, "TC" & [Time Card Hours].TimeCardID & "-" & [FirstName] & "
" & [lastname], "AUF", "DDR", "OpsMan";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top