Results 1 to 9 of 9
  1. #1
    tweety is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2012
    Posts
    126

    No Data on report error

    I have this code written when do data is found in the report



    Private Sub Report_NoData(Cancel As Integer)
    MsgBox "No Data to show on the report"
    DoCmd.Close

    End Sub

    it works fine, displays a error messge and doesnt load an empty report but i get the runtime error 2585 which stops the debug at this line

    DoCmd.Close

    any ideas anyone?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Try:
    Code:
    Private Sub Report_NoData(Cancel As Integer)
    MsgBox "No Data to show on the report"
    Cancel = True
    
    End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    tweety is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2012
    Posts
    126
    i have tried with your code, which solves the problem with the runtime error, however the line of code: "Cancel = True is" is showing another message saying: the openReport action was canceled. If i comment that line out then a blank report opens up. is there something so solve this.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    The error message is generated by the sub procedure that opens the report and can be dealt with by catching Err.Number 2501.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    tweety is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2012
    Posts
    126
    can you explain a bit more please? thanks

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Quote Originally Posted by tweety View Post
    can you explain a bit more please? thanks
    Sorry for the delay in making a reply. Take a look at the db attached. Post back if you have any further questions.
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    tweety is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2012
    Posts
    126
    i have tried to apply the error handling message in my system but iam having problems, how do i know which error code to put in?

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Quote Originally Posted by tweety View Post
    i have tried to apply the error handling message in my system but iam having problems, how do i know which error code to put in?
    The error handling code for the buttton called "Basic Error Handling" gives you the Err.Number value in a message box. This is the number that is tested for in the error handling code in the button called "Specific Error Handling". In this case it is 2501.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    You may find the following link of interest:
    http://www.fmsinc.com/tpapers/vbacode/Debug.asp
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Data mismatch error in Access report
    By ragpatil in forum Reports
    Replies: 9
    Last Post: 09-10-2012, 07:54 AM
  2. Replies: 3
    Last Post: 08-15-2012, 10:00 AM
  3. Replies: 5
    Last Post: 07-26-2012, 09:42 PM
  4. Replies: 7
    Last Post: 06-08-2012, 09:55 PM
  5. Replies: 1
    Last Post: 05-11-2012, 10:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums