Question : How can I prevent an event happening if I cancel an Access Report?

I am developing an Access 2007 "project" (.ADP) as a front-end to data in a SQL Server 2005 Express database.

One of my Access Reports prints "re-order prompts" to a group of customers. Each customer gets a separate page in the Report. In the GroupFooter0_Print event, if PrintCount = 1,  I execute a Stored Procedure to update a field in a SQL Server Table that records when a particular customer's Re-Order prompt was printed.

I start the Report with the following VBA code :

DoCmd.OpenReport strReportName, acViewPreview, , , , strLongOpenArgs
DoEvents
DoCmd.RunCommand acCmdPrint

This displays the first page of the report and offers the operator the usual Windows Print Dialog, from which they can choose the printer etc.

If the operator chooses to "Cancel" the report, everything immediately closes OK, but the Stored Procedure still gets executed for the first customer, even though it has not actually been printed.

Can anyone tell me where I should be placing my Stored Procedure call to avoid it being executed if the Report is cancelled?

Many thanks.

Answer : How can I prevent an event happening if I cancel an Access Report?

and BTW, your update code needs to be moved out of the report into the calling code after the RunCommand.

JimD.

Random Solutions  
 
programming4us programming4us