![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a main report with a subreport on it Occasionally the main report has no data whilest the sub report does have data. I want to supress the printing of the report only if both have no data. I use me.subRptLifePayments.Report.HasData to check, but that won't compile. Any ideas why not. Neither does me.subRptLifePayments.HasData or subRptLifePayments.Report.HasData or subRptLifePayments.HasData Thanks Phil |
#3
| |||
| |||
|
|
Phil wrote: I have a main report with a subreport on it Occasionally the main report has no data whilest the sub report does have data. I want to supress the printing of the report only if both have no data. I use me.subRptLifePayments.Report.HasData to check, but that won't compile. Any ideas why not. Neither does me.subRptLifePayments.HasData or subRptLifePayments.Report.HasData or subRptLifePayments.HasData Thanks Phil I created a 2 reports; Rpt1 and Rpt2. I then made Rpt2 a subreport in Rpt1. I dropped Rpt2 in the detail band. My code is: If Not Me.Rpt2.Report.HasData Then Me.PrintSection = False Me.MoveLayout = False End If It then prints only the records that have data in both Rpt1 and Rpt2. Not sure why yours doesn't compile. |
#4
| |||
| |||
|
|
On 25/10/2010 02:30:46, Salad wrote: Phil wrote: I have a main report with a subreport on it Occasionally the main report has no data whilest the sub report does have data. I want to supress the printing of the report only if both have no data. I use me.subRptLifePayments.Report.HasData to check, but that won't compile. Any ideas why not. Neither does me.subRptLifePayments.HasData or subRptLifePayments.Report.HasData or subRptLifePayments.HasData Thanks Phil I created a 2 reports; Rpt1 and Rpt2. I then made Rpt2 a subreport in Rpt1. I dropped Rpt2 in the detail band. My code is: If Not Me.Rpt2.Report.HasData Then Me.PrintSection = False Me.MoveLayout = False End If It then prints only the records that have data in both Rpt1 and Rpt2. Not sure why yours doesn't compile. Hi Salad Main report is called RptPaymentDaybook Sub report i SubRptLifePayments, no linkmaster of child field code is Private Sub Report_NoData(Cancel As Integer) Dim Msg As String Dim Stg As String Stg = Replace(DateField, "#", "") ' Get rid of Date # format Stg = Replace(Stg, "/", "-") ' repace the "/" with "-" If If SubRptLifePayments.Report.HasData = False Then ' No Life payments either Msg = "There have been no payments received " & vbCrLf Msg = Msg & Stg MsgBox Msg, vbInformation Cancel = True End If Exit Sub Now compiles OK, but I get Error 2455 "You entered an expression that has an invalid reference to the property Form/Report" Same error if I change it to your code If Not SubRptLifePayments.Report.HasData Then The subreport has in fact got data Thanks yet again for your help Phil |
#5
| |||
| |||
|
|
Phil wrote: On 25/10/2010 02:30:46, Salad wrote: Phil wrote: I have a main report with a subreport on it Occasionally the main report has no data whilest the sub report does have data. I want to supress the printing of the report only if both have no data. I use me.subRptLifePayments.Report.HasData to check, but that won't compile. Any ideas why not. Neither does me.subRptLifePayments.HasData or subRptLifePayments.Report.HasData or subRptLifePayments.HasData Thanks Phil I created a 2 reports; Rpt1 and Rpt2. I then made Rpt2 a subreport in Rpt1. I dropped Rpt2 in the detail band. My code is: If Not Me.Rpt2.Report.HasData Then Me.PrintSection = False Me.MoveLayout = False End If It then prints only the records that have data in both Rpt1 and Rpt2. Not sure why yours doesn't compile. Hi Salad Main report is called RptPaymentDaybook Sub report i SubRptLifePayments, no linkmaster of child field code is Private Sub Report_NoData(Cancel As Integer) Dim Msg As String Dim Stg As String Stg = Replace(DateField, "#", "") ' Get rid of Date # format Stg = Replace(Stg, "/", "-") ' repace the "/" with "-" If If SubRptLifePayments.Report.HasData = False Then ' No Life payments either Msg = "There have been no payments received " & vbCrLf Msg = Msg & Stg MsgBox Msg, vbInformation Cancel = True End If Exit Sub Now compiles OK, but I get Error 2455 "You entered an expression that has an invalid reference to the property Form/Report" Same error if I change it to your code If Not SubRptLifePayments.Report.HasData Then The subreport has in fact got data Thanks yet again for your help Phil I did a left join on Table4/Table5 (all Table4, exist Table5) In the query for Table4's recordsource I have HasID : IIf(Not IsNull([Table5].[ID]),True,False) Then in the band's OnFormat event If Not Me.HasID Then ... Endif Not sure why you code doesn't compile. You might have to create an alternative like the above. C'est la vie. In the OP you wrote "Occasionally the main report has no data whilest the sub report does have data. I want to supress the printing of the report only if both have no data." I don't even know how you accomplish having a subreport print that has no main record. That might be your problem. As Vinnie Barbarins said "I'm SO confused!" |
![]() |
| Thread Tools | |
| Display Modes | |
| |