Update fields after report has run

mveijndh

Registered User.
Local time
Today, 13:53
Joined
Dec 17, 2011
Messages
113
Hi Guy's
How can i run an update query after I've ran a report for for instance mileage reports?
To explain more clearly:
Code:
SELECT tblMileage.EmployeeID, tblMileage.MileageDate, tblMileage.MileageDetails, tblMileage.MileageDistance, tblMileage.MileageClaimCost, tblMileage.MileageClaimed, tblMileage.MileageClaimDate, tblOrder.CAEJobNumber
FROM (tblMileage INNER JOIN tblCompany ON tblMileage.CompanyID = tblCompany.CompID) INNER JOIN tblOrder ON tblMileage.OrderID = tblOrder.OrderId
WHERE (((tblMileage.EmployeeID)=[Voor wie? M=1,L=2]) AND ((Month([MileageDate]))=[Welke maand]))
ORDER BY tblMileage.MileageDate DESC;
I run the following query. the query askes me for whom and what month. after I've provided the data, I get the report for all mileage.
What I want to accomplice is the field tblMileage.mileageClaimed is set to true and the field tblMileage.MileageClaimDate should get the current date, after the report has run and generated the pdf file I want to print.
Any suggestions?
 
How is the report produced?
If it's via VBA, you can add a couple of lines after it's run to do the things you want.
 
Yes, the report can be produced via VBA. I do have to find the details, but I think I'll run this from a centralizes file library.
I'm reasonable familiar with VBA, just don't know enough of the details
 
Code:
 DoCmd.RunSQL "UPDATE tblMileage SET MileageClaimed = {the value} WHERE {some condition};"
  
 DoCmd.RunSQL "UPDATE tblMileage SET MileageClaimDate = #{the date}# WHERE {some condition};"
 [code]
 
So if the WHERE claus is the same as the Where clause in the selection, It would be fine. I assume I can update both fields in the same DoCMD as that would change one of the factor in the Where clause, like below?

DoCmd.RunSQL "UPDATE tblMileage SET MileageClaimed = {the value} SET MileageClaimDate = #{the date}# WHERE {some condition};"
 
Yes, but you may need a comma between the two updates (I forget the actual syntax at the moment).
Something like
Code:
 DoCmd.RunSQL "UPDATE tblMileage SET MileageClaimed = {the value} , MileageClaimDate = #{the date}# WHERE {some condition};"
 

Users who are viewing this thread

Back
Top Bottom