Pend printing reports

y2k

Registered User.
Local time
Today, 13:21
Joined
Mar 11, 2002
Messages
36
I currently have an Access2000 database with an AutoExec Macro which prints a number of reports every morning so that they're ready for use when employees arrive for work. However, sometimes these reports have no data on them, depending on what was received the day before. Is it possible to create a module (or in some other means if necessary) so that any reports which do not have any data in them would not print?
 
That's not working. What am I doing wrong? On the On No Data I entered DoClm.Close but that didn't work. I entered it as an expression also but that didn't work either. What am I doing wrong? Also, seing that not all of these reports will be pringint (once I know where I'm gone wrong!!) Is there any way I can generate a report listing all the reports which did print, so that the users will know if any are missing or not? I know that I would probably have to desing the report myself, but could I make it include/exlucde the reports from the list based on whether there are any data in them or not? I hope I'm making sense???
 
Open the property sheet for the report in the On No Data line put [EventProcedure] click the build button the code window should now open and look like
Private Sub Report_NoData(Cancel As Integer)
End Sub

In between the lines put DoCmd.Close
it should now look like
Private Sub Report_NoData(Cancel As Integer)
DoCmd.Close
End Sub
Click the Debug button on the menu bar select compile and save all modules.
The answer to your second question is yes in theory, simply add a field to a table fldDtePrinted when the reports Unload event occurs update the field to todays date. Problem is of course that if the printer jams, runs out of paper etc. the date will still be recorded and you'll have to replace DoCmd.Close with Cancel=True, you'll then have to add further code from preventing the standard msg from displaying.
Gets more involved the deeper you delve I'm afraid
HTH
 
It still generated an error. However, when I changed it to DoCmd.CancelEvent it worked. The report won't open now except in design view, but that's not a problem as nobody ever needs to open them - they work off the printed hard copies. Will this cause any other problems for me? It seems to be working fine. I haven't tried doing the other report yet. Running out of paper isn't really an issue on that one. But they may decide the report's not necessary. I have 2 final questions! One, is there any way to password protect my tables, queries etc from being viewed, ie when somebody clicks on Tables, they'll be prompted for a password. Second, is there anyway to generate a MsgBox if a user tries to print a report but there is no data in the report?????

Thanks for ALL your help.
 
OK, I need help again. I have over 150 Reports and when I pasted the DoCmd.CancelEvent into each one, I started getting out of memroy errors after about 40 of them. Is there any way to create one module which cancels the print each time it's called? Please somebody help me, I don't know what else to do. The DoCmd.Close doesn't stop it from printing. Maybe that's because it's being printed using a macro? I've tried using a macro to call in a module with DoCmd.CancelEvent in it, and then using that as the onNoData event, but that just cancels the Macro, not the report printing. Am I making sense? Please, I need help. thanks
 
In place of the macro, use the OnNoData event procedure. I just use

Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data to be printed in this report."
Cancel = True
End Sub

I have about 100 reports and don't get any memory problems.

David
 
Assuming your macro contains multiple open report statements I suspect it would be better to use a Module to open the reports adding error handling the Autoexec would then RunCode.
HTH
 
I explained myself badly. It's when I'm putting in the code that I'm getting the out of memory errors. After I've put the code in about 40-50 of the reports, when I go to put it into the rest of them , I start to get the errors. I'm only getting them in access. Every other application runs fine.

Rich, your idea about having a module to print the reports is a good idea. Can you help me out on the code though? I only know the very basics of VB.

Thank you all so much for your help.

[This message has been edited by y2k (edited 04-02-2002).]
 

Users who are viewing this thread

Back
Top Bottom