Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running a report between certain times

Status
Not open for further replies.

jalge2

Technical User
Feb 5, 2003
105
US
The scenario, and auto scheduler that doesn't run at exactly 8 oclock in the morning. It might run at 8:01 or so. Testing it, I can run it right at 8 and it works but what if it's 8:01. How do I run it between certain times. Here's my code


If Time #8:00:00 AM 8:30 AM# Then
DoCmd.openreport "Printlog", acViewNormal

ElseIf Time > #8:00:00 AM# Then
DoCmd.openreport "New Report", acViewNormal

End If

I appreciate the help.

Jason
Lowe's Home Improvement Warehouse
 
I would use Windows Task Scheduler to launch the report at a specific time. In the database window, select the report you want and right click and select Create Short Cut... Then in Windows Task Schedule, schedule the short cut to run at the time you specify.
 
Just so everyone knows, that's not the problem. I have the scheduler part figured out, but there are times that it might not run exactly at 8 oclock, it might run at 8 oclock and 15 seconds, or 8:01. That's why I need to figure out how to look between times.
 
What about something like this:

If (TimeValue(Now()) >= cdate(&quot;8:00:00&quot;)) and (TimeValue(now()) <= Cdate(&quot;8:00:59&quot;)) then DoCmd.openreport &quot;Printlog&quot;, acViewNormal

ElseIf (Timevalue(now()) >= cdate(&quot;8:01:00&quot;)) Then
DoCmd.openreport &quot;New Report&quot;, acViewNormal

End If
 
I think you have a design problem here.

what if someone fails to open the database in the prescribed time window.

I believe the suggestion to use the scheduler is very appropriate.

Have the scheduler invoke your database with a specific command line option.

When your database starts up, the AutoExec macro can call code that detects the command line option, prints the report (based on Time of Day) and exits.

The code to find if the time of day is appropriate could then be simply (and roughly):

if time() < #9:00AM# ...
else if time() < #5:00 PM# ...
 
Thanks for the discussion. This is an area I will need to address in a coming project and this helps get me thinking about how best to do it.

Have a great day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top