Hi John, I put the On Error Resume Next before my DoCmd.OpenReport statement and it worked. I don't understand it, but I am very happy it works. Thank you again for all your efforts and patience. Ilona
-----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] Behalf Of John Viescas Sent: Monday, 5 June 2006 5:22 PM To: [email protected] Subject: RE: [ms_access] On No Data Help Please Ilona- Add an error trap around your DoCmd.OpenReport. Setting Cancel = True creates a trappable 2501 error - your code canceled the action requested by the OpenReport. It could be as simple as: On Error Resume Next DoCmd.OpenReport ... John Viescas, author Building Microsoft Access Applications Microsoft Office Access 2003 Inside Out Running Microsoft Access 2000 SQL Queries for Mere Mortals http://www.viescas.com/ (Paris, France) For the inside scoop on Access 2007, see: http://blogs.msdn.com/access/ -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Ilona Wright Sent: Monday, June 05, 2006 7:43 AM To: [email protected] Subject: RE: [ms_access] On No Data Help Please Hi John, In the On No Data event of my Computer Register report I have Private Sub Report_NoData(Cancel As Integer) MsgBox "There is no data for this report. Canceling report..." Cancel = -1 End Sub On pressing Enter to the MsgBox I get the error Run-time error '2501' The OpenReport action was cancelled. You used a method of the DoCmd object to carry out an action in Visual basic, but then clicked Cancel in a dialogue box. For example, you used the Close method to close a changed form, then clicked Cancel in the dialogue box that asks if you want to save the changes you made to the form. The Debug takes me to the DoCmd.OpenReport line that opened the report. If there is no data, how do I cancel the report and cleanly get back to my form? Thanks again in advance Ilona [Non-text portions of this message have been removed] Yahoo! Groups Links SPONSORED LINKS Microsoft access database Database development software Database management software Database software Inventory database software Membership database software ---------------------------------------------------------------------------- -- YAHOO! GROUPS LINKS a.. Visit your group "ms_access" on the web. b.. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. ---------------------------------------------------------------------------- -- [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> Protect your PC from spy ware with award winning anti spy technology. It's free. http://us.click.yahoo.com/97bhrC/LGxNAA/yQLSAA/q7folB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/ms_access/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
