How to print long report in the midnight

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

I must print 2 Access reports every day. The report is
quite large and usually it takes longer than 30 minutes to
print one of them. Is there any good way to write an VBA
code to set a timer in order to run the printing task in
midnight?
 
-----Original Message-----
I must print 2 Access reports every day. The report is
quite large and usually it takes longer than 30 minutes to
print one of them. Is there any good way to write an VBA
code to set a timer in order to run the printing task in
midnight?
.

Reply,

Hi Sam,

One suggestion would be make 2 new access databases and
all the do is print what you require. Then set up
Scheduled taks on your computer to open each new database
in turn at different times. Suggest 2 hours apart to
allow for extra growth. Don't forget to use the startup
on the tools menu to go to a form called say print
report. Then use a macro or VBA to print the file.

Hope this helps.

Good luck.

ps I suggest do not try and re-invent the wheel when it
is already there.
 
You would use the timer event of a form to call the OpenReport code. Set the
Timer Interval to 1000 (1 second). In the timer event:

Static bolPrinted As Boolean
If Time >= #00:00:00# And Time <= #00:00:05# And bolPrinted = False Then
DoCmd.OpenReport "MyReport"
bolPrinted = True
Else
bolPrinted = False
End If

If the 5 second interval above isn't sufficient, you could increase. Another
way of doing this would be to have a table that you log each print in then
check that date to see if you need to print. The advantage of the second way
would be that if the report didn't print at midnight (i.e. if Access or the
form was closed), then it would print as soon as the form opened.
 
Hi, Ian:

Thanks for your prompt response. I shouldn't mention I
have 2 reports to print. Actually my real question is not
multiple reports, but how to start printing report
automatically on pre-set time. You mentioned setting up
scheduled task and use VBA code... It is what I like to
know but no clue. Let me make it clear: I want to know how
write the code to timer my printer to print the report in
mide night when I don't have to get up and run to my
office to do the job. I know how to write VBA code but
don't how to progragm this event. Could you please give me
a little detailed guidence? Thanks.

Sam
 
Wayne:

Thank you for your prompt response and the hint. Could you
give me a little more detailed guidence. I can let the
access database open overnight and stop the screen. Assume
there is only one report to print in mid night. How to
write an event procedure to do so? Thanks.

Sam
 
I gave one example of doing this in my previous post. The code would go in
the form's Timer event. Is there something else you would like to have it do
also?
 
Wayne:

Before I see your post this morning I have already tried
your solution. It works. However,I don't understand why
you added a varible bolPrinted? It is for record keeping?
Thanks.

Sam
 
The time range in the If statement could theoretically be satisfied 5 times
since it is set for 1000 ms (1 second) intervals. If you make the window too
tight, you may miss it. The timer function may not check exactly on the
second, so we have to give a time window. However, with a window, if we hit
it more than once we may print the report more than once. The boolean
variable (true/false) just checks to see if we have printed once already and
if so skip the print because we've been through the window one time. Once we
are outside the print window, we reset the variable to false so that when we
hit the print window tomorrow it will print again.
 
Wayne:

Thank you again for your detailed explantion. Actually
before I read your explanation, I already got it. I read a
book and knew first time there is a form_time event (I
stuck this afternoon for trying to figue out how make a
general module...). When I made the form event, it works
immediately. In my trying, I already encountered both
multiple printing and missing reaction. However, the most
frequently problem is multiple printing. Now I am thinking
I may remove the static key word and add a button on the
form to reset the bolPrinted as false before reuse the
timer form. Again, thank you so much. I will never forget
your help. Regards,

Sam
 
Back
Top