Conditional page break question (1 Viewer)

KSawyer

New member
Local time
Today, 13:56
Joined
Feb 4, 2018
Messages
4
Hi
I have a membership directory where some records are a single page and some are 2 pages. I want it to print double sided, with each new member's record starting on the Right hand page (odd # page). So a 2 page record would print front/back, and the next record printing as I want, on the next odd page. A one page record, should force a new page so that the following record will NOT print on the back of the one page record, but would appear on the next odd page. In the situation of a one page record, we need a page break.
I have searched the forum for the text of the code to be used, and it didn't work. Probably because I now NOTHING about programming. It's not clear to me whether I should put the page break symbol in the footer, or in the detail section, or no where. Where would the code go? In the detail section, or the page footer? This is the code I used (in both sections)

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Me.Page Mod 2 > 0 Then
Me.PageBreakX.Visible = False
Else
Me.PageBreakX.Visible = True
End If
End Sub

When I tried Print Preview, I got an error code : "Method or Data Member Not Found". I have no idea what to do.
Thanks in advance for any help you can provide :)
 

llkhoutx

Registered User.
Local time
Today, 15:56
Joined
Feb 26, 2001
Messages
4,018
Instead of using "Me," use Reports!YourReportname!YourControlName.
 

KSawyer

New member
Local time
Today, 13:56
Joined
Feb 4, 2018
Messages
4
Still not there.
A couple questions
1) Here's the code I used

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Reports!All Members Report!Rig Number.Page Mod 2 > 0 Then
Reports!All Members Report!Rig Number.PageBreakX.Visible = False
Else
Reports!All Members Report!Rig Number.PageBreakX.Visible = True
End If
End Sub

I'm not quite sure what the YourControlName is. If you mean the field that prompts a new page (in the printing process), then it is Rig Number

I tried this with and without the 'Insert Page break' command (at the end of the detail section. I tried this code in the header, detail and footer sections. What section should it go into?

These are the error codes I saw:
1) This command will stop the debugger
2) Custom macro has failed to run an is preventing report from rendering
3) Compile error - expected End sub (on this one, I added another End Sub. Didn't solve the problem.

So you can see ... I'm over my head. thanks for any help you can give me.
K
 

JHB

Have been here a while
Local time
Today, 22:56
Joined
Jun 17, 2012
Messages
7,732
You put the page break in the detail section.
And the code goes in Detail_Format event.
Actually I don't think the name of the page break control is "PageBreakX", to find the name of it, put the report in design view and mark the page break, look at the name the property sheet shows.
Replace the "PageBreakX" in the code, with the name the property sheet shows you.
Unlike llkhoutx I would advise you to use Me. instead of reference to the report name, it makes the code easier to read and so the code is also not vulnerable, if you later decide to change the report name.
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  If Me.Page Mod 2 > 0 Then
    Me.[COLOR=Red]PageBreakX[/COLOR].Visible = False
  Else
    Me.[COLOR=red]PageBreakX[/COLOR].Visible = True
  End If
End Sub
 

KSawyer

New member
Local time
Today, 13:56
Joined
Feb 4, 2018
Messages
4
Yeah!!!! I am so excited. The report us beautiful. I thank you so much for sticking with me to get it right. You rock !!
 

JHB

Have been here a while
Local time
Today, 22:56
Joined
Jun 17, 2012
Messages
7,732
You're welcome.
 

Users who are viewing this thread

Top Bottom