0
votes

In my DB i have a table called "PrintList" populated with a random number of records and a report called "ReportList", which is linked to "PrintList", that is used to print all the records of the table above.

EDIT: I would let the user to see a print preview in Access to check the list and then choose if print it or not, so i prefer to avoid using code to print.

Is it possible to handle the "ReportList" print event and delete all "PrintList" records after the report is printed? Right now I use a button to empty the list via SQL, but it will be more useful to empty it after printing it.

2
Why you dont put the code of the Button after the code that print those record? - Juanche
Because i would let the user to see a print preview using Access interface to check the list and then print it, if it'spossible i prefer to not print using a vba code. But if there isn't a way to do this i will use code for printing and erasing records for sure. Thank you, i've realized just now that my description of the situation was incomplete. - rukawa
Is there any reason your records NEED to be in a table? Can you populate your report with an in memory recordset instead? Then there are no records to clear after printing. - Brad
It's a good idea but i've some troubles populating the recordset. I'll explain: I've a form where the user can search objects from a warehouse items list. If he wants by pressing a button he can insert (or remove) the current object in a print list. Then he can browse again for other objects and add them to the print list. Then he can print the list to go to the warehouse and know where the items are located. After the print I would automatically erase this list so next time he search items and print lists it will start from a blank list without leaving him to empty it by pressing buttons. - rukawa

2 Answers

1
votes

Report/section events like On Format or On Print are fired both for Print Preview and for actual printing. So the report doesn't know, and thus can't handle your requirement.

I'd use a form with buttons for Preview and Print, and delete the records when the form is closed (because you can't prevent the user from printing from the preview).

The whole requirement looks a bit strange, TBH.

0
votes

Open your report in design mode.

If the properties pane on the right isnt visible, press F4 to make it visible.

In the properties pane, click on the Events tab.

Find the OnPrint event and click the little ellipses to the right of it to open a VBA window ready to accept your code for that event.