Microsoft Access Office VB VBA Help and Examples
           
             

How to simulate odd and even margins (book style) in a report

This example shows how to simulate a left hand margin on even pages and a right hand margin on odd pages. This is useful if you want to print double sided but want a larger margin in the binding area or opposite edge, for notes or similar.

Trying to physically change the margin on each page is to difficult. What is easier is to move the controls on the page back and forth. Even easier than that is to move a sub report left and right.

In a report you have an on format event in the page format event you should be able to access the left property of a control here's an example that works by moving a textbox called word based on wether it was an odd or even page...

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)

  If FormatCount > 1 Then Exit Sub
    If Me.Page Mod 2 = 1 Then
    Me.Controls.Item("Word").Left = 1650
  Else
      Me.Controls.Item("Word").Left = 550
   End If
End Sub

It's very important to remember that in the on format event each time you move a control it takes effect for all pages that haven't been formatted yet (i.e. all pages going forward) so you must move the control back on the next page.

 
HOME   SEARCH SITE   PRIVACY POLICY   CONTACT
The code and application content of this site is copyright of Smiley I.T. and as such reproduction in any form which is for commercial use requires the permission of the Webmaster. Any use of this code for non-commercial use only requires a link or comment back to the original page you took the code from.