Report Events

BloodshotVandal

Registered User.
Local time
Today, 10:06
Joined
Nov 19, 2009
Messages
17
Hi All

I was wondering if someone could help me with a problem I am having with the way one of my reports is printed.

I have a report with page and resize events that determine which fields will be displayed/hidden based on their values. If I open the report normally then print everything prints correctly but if I print directly from a form (where I have a button the user can click to print the report) the first page ends up being formatted incorrectly.

I can't seem to figure out how to correct this. I tried the "On load", "On Open", and "On Activate" events which didn't seem to solve the problem. Any advice would be greatly appreciated.

Thanks
 
In what event are you performing the formatting? OnFormat or OnPrint?

Try to wrap your code in If FormatCount = 1 Then block for the OnFormat even or If PrintCount = 1 Then block for the other.
 
Hi vbaInet, thanks for replying.

In my report, in the Resize and Page events I have the following:
Code:
Public Function SetVisibility()
    If Me![text09] = 0 Then
         Me.text09.Visible = False
         Me.label09.Visible = False
         Else
         Me.text09.Visible = True
         Me.label09.Visible = True
    End If
End Function

Private Sub Report_Page()
    SetVisibility
End Sub

Private Sub Report_Resize()
    SetVisibility
End Sub
In my form I have the following
Code:
Public Function PrintReport()
    DoCmd.OpenReport "rptMyReport", acViewNormal
    DoCmd.Close acReport, "rptMyReport", acSaveNo
End Function

Private Sub cmdPrintReport_Click()
    PrintReport
End Sub
When I click the print button in the form all the pages except the every first page is printed correctly.
 
So what's the idea behind using those two events?

In what section are these controls situated? Detail, Header or Footer? The reason I ask this particular question is just to know whether the code is run only once.
 
Most code for making controls visible and whatnot needs to be in the On FORMAT event of the section the controls are in. Resize and page events are normally not going to work with what you are attempting.
 
Hi guys thanks for replying.

The On Format event (when I finally found it) did the job, it works fine now.
 

Users who are viewing this thread

Back
Top Bottom