Report_Close event

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top