Subreport Nightmare

mark curtis

Registered User.
Local time
Today, 20:45
Joined
Oct 9, 2000
Messages
457
Dear all,
This must be the tenth time I have asked the experts this and I still can not get my head around it.

I have a main report and in the detail section I have 7 subreports.

When I run the main report if any of the subreports do not have any data I want to show a label from either the main report or subreport that says no data for this subreport.

Each subreport is linked by projectid and they are master/child in correct order.

Please help?

Please tell me what events to put any code in?

I am struggling.

Thanks
Mark
 
Have you tried the "On No Data" property for the subreport?
 
Chris,

I know what the OnNoData property is but when do I use it?

If the subreport closes how do I tell the main report to show the label "No data"?

I need to know the events of a report run?

Thanks
Mark
 
I haven't tried it but something like If Me.SubreportName.HasData = False Then
Etc
 
---Posted by Dev Ashish---

--------------------------------------------------------------------------------
Reports: Close report automatically if no data found
--------------------------------------------------------------------------------


(Q) How can I close a report automatically if there's no data returned by the underlying query?

(A) You can use the Report's OnNoData event for this. For example, the following code

'************* Code Start *************
Private Sub Report_NoData(Cancel As Integer)
MsgBox "No data found! Closing report."
Cancel = True
End Sub
'************* Code End *************
will automatically close the report if there are no records in the underlying source.



However, if you're opening the report from code behind a form, you need to handle the error that's generated as a result.

'*********** Code Start ************
Private Sub TestNoData_Click()
On Error Resume Next
DoCmd.OpenReport "SomeReport", acViewPreview
If Err = 2501 Then Err.Clear
End Sub
'*********** Code End ************
 

Users who are viewing this thread

Back
Top Bottom