How to close the POS report automatically if the print failed

Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc used Ask the Experts™
on
I want the Point of sales report to close automatically either after printing or if it failed to print , how do I do it , please do not worry about the the attached action queries they are there to handle the double entry only , below is my VBA code:

Private Sub CmdPos_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery "QryRevenueAccount"
DoCmd.OpenQuery "QryCostofSales"
DoCmd.OpenQuery "QryStockAccount"
DoCmd.OpenQuery "QryVatAccount"
DoCmd.OpenQuery "QryReceiptsAcc"
DoCmd.Save
DoCmd.OpenReport "rptPosReceipts", acViewPreview, , "ItemSoldID =" & Me.ItemSoldID
DoCmd.PrintOut , , , , 1
DoCmd.Close acReport, "rptPosReceipts"
Me.Refresh
End Sub


See how the above code can be amended.

Regards

Chris
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software & Systems Engineer
Commented:
Failed to print
If this happens due to NoData then simply put on the NoData Event of the report to close if no Data present
else
Put an Error Handler so if an Error pops up when you try to print the report to check if the Reports collection has the report Open and close it.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial