J
Joseph Greenberg
When I close my report, some of my code that controls the left margin for
odd-even pages runs many times before the report actually exits - it's in
some kind of loop but does eventually close.
The code in my report is as follows:
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
If Me.Page = 1 Then
MoveMargin = 360
ElseIf Me.Page Mod 2 = 0 Then
MoveMargin = -360
Else
MoveMargin = 360
End If
ChangeMargins
End Sub
Public Sub ChangeMargins()
Printer.LeftMargin = Printer.LeftMargin + MoveMargin
If Me.Page = 1 Then Exit Sub ' the default margins are set up for the first
page
If Me.Page Mod 2 = 0 Then
With lblPageHeader
.TextAlign = 3
.Left = 4140
End With
With txtPageNumber
.TextAlign = 1
.Left = 0
End With
Else
With lblPageHeader
.TextAlign = 1
.Left = 0
End With
With txtPageNumber
.TextAlign = 3
.Left = 4140
End With
End If
End Sub
Private Sub Report_Close()
Printer.LeftMargin = 720 'if the report has an even number of pages, it
resets the report margin away from the way it was set up originally
End Sub
Private Sub Report_Load()
Printer.LeftMargin = 720 ' ensures the margin is where it is supposed to be
End Sub
The code that seems to be repeat firing is ChangeMargins(). Any ideas why
this might be happening?
odd-even pages runs many times before the report actually exits - it's in
some kind of loop but does eventually close.
The code in my report is as follows:
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
If Me.Page = 1 Then
MoveMargin = 360
ElseIf Me.Page Mod 2 = 0 Then
MoveMargin = -360
Else
MoveMargin = 360
End If
ChangeMargins
End Sub
Public Sub ChangeMargins()
Printer.LeftMargin = Printer.LeftMargin + MoveMargin
If Me.Page = 1 Then Exit Sub ' the default margins are set up for the first
page
If Me.Page Mod 2 = 0 Then
With lblPageHeader
.TextAlign = 3
.Left = 4140
End With
With txtPageNumber
.TextAlign = 1
.Left = 0
End With
Else
With lblPageHeader
.TextAlign = 1
.Left = 0
End With
With txtPageNumber
.TextAlign = 3
.Left = 4140
End With
End If
End Sub
Private Sub Report_Close()
Printer.LeftMargin = 720 'if the report has an even number of pages, it
resets the report margin away from the way it was set up originally
End Sub
Private Sub Report_Load()
Printer.LeftMargin = 720 ' ensures the margin is where it is supposed to be
End Sub
The code that seems to be repeat firing is ChangeMargins(). Any ideas why
this might be happening?