dbTalk Databases Forums  

Sub reports

comp.databases.ms-access comp.databases.ms-access


Discuss Sub reports in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Phil
 
Posts: n/a

Default Sub reports - 10-24-2010 , 12:19 PM






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

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Sub reports - 10-24-2010 , 08:30 PM






Phil wrote:
Quote:
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.

Reply With Quote
  #3  
Old   
Phil
 
Posts: n/a

Default Re: Sub reports - 10-25-2010 , 10:50 AM



On 25/10/2010 02:30:46, Salad wrote:
Quote:
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

Reply With Quote
  #4  
Old   
Salad
 
Posts: n/a

Default Re: Sub reports - 10-25-2010 , 11:33 AM



Phil wrote:

Quote:
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!"

Reply With Quote
  #5  
Old   
Phil
 
Posts: n/a

Default Re: Sub reports - 10-25-2010 , 05:46 PM



On 25/10/2010 17:33:21, Salad wrote:
Quote:
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!"

Hi Salad
Code now compiles OK, but the runtome error is as above.
The main report is based on a table of membership fee payments (PaymentID,
PayAmount, PayDate MemberID (FK) .... The Subreport is for life membership
payments which is a one off payment held on the Member table. Normally there
are membership fee payments on pretty well a daily basis but life membership
is a pretty rare occurance. So I had not spotted a problem till the
inevitable day (Sunday) when the girl who posts the membership fee payments
was off, and I posted a life payment and of course the transaction didn't
print out. The report is done pretty well each day and accompanies the
cheques when they are payed into the bank. Fees are due at this time of the
year, so we get a rush in October and November, the we have a period of no
money coming in. There is a date entry form to select the period for which we
want to print the money received, and if no money has been received for that
period (either membership fees or life membership) we want an informatitive
message. If only life membership is received I need just to print the headers
of the main form and the subform

Thanks again

Phil

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.