Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 10th, 2007, 12:27 AM
Authorized User
 
Join Date: Mar 2007
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default Report Problem with On No Data

Hi All,

My DB opens a report from another form which the user selects certain print options. I have set an On No Data event on the report which if opened displays a message box (advising user of no data)and then cancel event (which closes the form). This part works fine if i open the report directly. However my problem is i open this report from another form and i get a run time error after the "On No Data" event runs on the report itself. When i click on the debug the error goes to line "DoCmd.OpenReport stDocName, acViewNormal" on the form. The Error code is 2501 : The OpenReport action was cancelled.
My code On My Form to open the Report is as follows
If (Forms!frmSOBStatMenu!Frame3 = 2) And (Forms!frmSOBStatMenu!Frame4 = 1) Then
    stDocName = "rptXtabClmsByYearSumm"
    DoCmd.OpenReport stDocName, acViewNormal

    Else
    If (Forms!frmSOBStatMenu!Frame3 = 2) And (Forms!frmSOBStatMenu!Frame4 = 2) Then
    stDocName = "rptXtabClmsByYearSumm"
    DoCmd.OpenReport stDocName, acViewPreview

Now if the report has not data the OpenReport stDocName runs then the On No Data event runs from the report, i get the message box advising user of No Data, then because i dont want the report to open i cancel event from the On No Data, thats when i get the run time error.

Any Ideas

Thx in advance

Darren
 
Old April 13th, 2007, 09:20 AM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Have you tried either turning off the error messages or using an onerror trap?

Another way to do this if that doesn't work is to open the database yourself and check for recordcount < 1 prior to calling the form.

 
Old April 13th, 2007, 06:04 PM
Authorized User
 
Join Date: Mar 2007
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Allenm

After Much Pain, i took ur advice and turned off error messages, and wellah!!! The code runs fine now.


Thanks for your help

Cheers

Darren






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in refersh data report Rajesh Pachouri Pro VB Databases 1 September 27th, 2006 03:45 AM
problem in data report Rajesh Pachouri Pro VB Databases 1 September 18th, 2006 07:05 AM
Data Report Problem jnl207 Pro VB 6 2 April 10th, 2006 05:49 AM
VB data report problem lalraj Access VBA 1 April 26th, 2005 06:38 AM
retrieved data report problem rahmanbd Beginning VB 6 0 March 18th, 2005 08:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.