Check when report was run last

  • Thread starter Thread starter RobertG
  • Start date Start date
R

RobertG

Hi all,

I have a report that is run from the OnClick event of a command button.
When this occurs, a query is ran that updates the UserID and ReportDate in
tblReportHistory with their respective values.

What I would like to do is display a msgbox if the last time the report was
run was before the 16th of the current month.

I know I need to check for the current date, date the last time the report
was run, and compare the two. I'm thinking I need to use the DateSerial
function to achieve my goal, but I have no idea how to do so.

Any help/suggestions?

Feel free to ask for additional info, if needed!

Robert
 
If you have a command button, I'll assume you are working in a form.

If so, what about adding a control on the form that displays the "last date
run"?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Your assumption is correct and, yes, I could add a control to display the
last ran date; however, I'm worried that my end users will just overlook the
date and not rerun after the 16th. I've found that holding their hand as
much as possible is usually for the best. ;)

That being said, is there any way to display a msgbox alerting them that the
last date it was ran was before the 16th of the current month and that it
needs to be ran again? If not, I'll go with your idea and wish for the best.
:)

Robert
 
On Mon, 3 Mar 2008 17:07:00 -0800, RobertG

You probably meant: if today is past the 16th and the last time run is
before the 16th, then it needs to be run again.

I would do a test at startup time.
Assumptions: You have a function GetUserID that returns the current
UserID, and it is numeric.

if Day(Date) > 16 and DLookup("ReportDate","tblReportHistory",
"UserID=" & GetUserID()) then
If Msgbox("Report needs to be run again. Do it now?",vbYesNo or
vbQuestion) = vbYes then DoCmd.OpenReport .....
end if

-Tom.
 
Back
Top