Conditional Page Break Boiler Text and sub report (1 Viewer)

sxschech

Registered User.
Local time
Today, 03:20
Joined
Mar 2, 2010
Messages
792
Started using Access 2016.

I have a report that has boiler plate text and added a subreport. All is well if the subreport has at most 2 records (screen shot). I would like to specify a page break (where highlighted in screen shot) on the main report if the subreport has more than two records. I tried this code in the Detail_Print:
Code:
       If Me.txtListCount > 2 Then
        Me.PageBreak120.Visible = True
    Else
        Me.PageBreak120.Visible = False
    End If
Didn't seem to work for me. Page still breaks regardless of true/false. I stepped through the code and it is following the logic. Another suggestion said to set the page break visible property to false, I did not see that option in the property sheet of the page break control. Since the page break doesn't relate to grouping I don't think can use the keep together or force new page after stuff.
 

Attachments

  • ConditionalPgBreak.PNG
    ConditionalPgBreak.PNG
    14.2 KB · Views: 86
  • ConditionalPgBreakDesign.PNG
    ConditionalPgBreakDesign.PNG
    21 KB · Views: 87

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:20
Joined
May 7, 2009
Messages
19,233
Maybe you can create a dummy group an put that extra text to the group footer.
 

isladogs

MVP / VIP
Local time
Today, 11:20
Joined
Jan 14, 2017
Messages
18,209
You need to place the code in the Format event for that section so it takes effect BEFORE printing.
The Print event is too late as the formatting has already been done!
 

sxschech

Registered User.
Local time
Today, 03:20
Joined
Mar 2, 2010
Messages
792
Thanks Colin. Putting in the Detail_Format event solved the issue. I often get confused as to when to put something in Detail_Print vs Detail_Format or is better just to always put code in Format rather than Print?
 

isladogs

MVP / VIP
Local time
Today, 11:20
Joined
Jan 14, 2017
Messages
18,209
I've never yet used the On Print event in any report in 20 years...
 

Users who are viewing this thread

Top Bottom