Reports

kwin

New member
Local time
Today, 20:19
Joined
Aug 26, 2008
Messages
8
The report I am using has subreports in it. The problem is some time there is no data in this subreport, I would like a comment in the report saying "no data this quarter"
How can this be done?
 
Hi Kwin,

This is what I have in one of my report's No Data event.

Code:
Private Sub Report_NoData(Cancel As Integer)
' Display a message if there are no receipts to be printed
' and don't preview or print report.

    Dim strMsg As String, strTitle As String
    Dim intStyle As Integer
    
    strMsg = "There are no receipts to be printed."
    intStyle = vbOKOnly
    strTitle = "No Data"
    
    MsgBox strMsg, intStyle, strTitle
    Cancel = -1
 End Sub

Regards,
Chris
 
Hi Chris

thanks for the info, I have used your code but,

let me explain what I am trying to do

I have a main report with 8 subreports in it

I need to beable to print all the reports, sometimes there is no data in 1 of the subreports.

Can a message be printed on the subreport saying "no data"

thanks
kwin:o
 
Hi Kwin,

Unfortunately, I have never played with what you're attempting and I'm not sure how to do it. I did some digging and found the following link for a similar question.

http://help.lockergnome.com/office2/data-show-ftopict712036.html

I'm running Access 2003 and I tried the 2 suggestions but I only managed to get a blank page to open.

This posting is 4 years old so I doubt that it applies as is to 2003 or later versions of Access.

Maybe one of the forums VIP's can shed some light on this.

Chris
 
Hi Chris

thanks for your help, I have found one thread "sub reports no data" this guy had a main report with 6 sub reports, he used the header for the message to appear if there was no data per page.

But my report has two subreport per page so I just have to work out how to code it.

If you have any idea let me know please

thanks kwin :o
 
Hi Chris

I used the link you gave me, and made some small changes to it

What i did

In the report's Design View
  • Add a Label call it Label1
  • You need to type something in it so it will stick - it doesn't matter what
  • In the Properties box set the label's Visible property to No.
In the Subreport

  • In the Subreport NoData event Procdure use the following code

    Dim Ctrl As Control

    For Each Ctrl In Me.Controls
    If Ctrl.Name = "Label1" Then
    Ctrl.Caption = Me.Caption & " has no data."
    Ctrl.Visible = True
    Else
    Ctrl.Visible = False
    End If
    Next ctrl
Thanks for your help

kwin :eek:
 
Glad to hear that it worked for you. Thanks for posting back.

Chris
 

Users who are viewing this thread

Back
Top Bottom