textbox.visible = false Not Working in Report

TheSearcher

Registered User.
Local time
Today, 18:54
Joined
Jul 21, 2011
Messages
408
I have the following code in the On Print event of my report footer:
Code:
Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)

If Me.Page = 1 Then
     MsgBox Me.Page
     Me.[lbl_ClientName_Footer].Visible = False
     Me.[txt_ClientName_Footer].Visible = False
Else
     Me.[lbl_ClientName_Footer].Visible = True
     Me.[txt_ClientName_Footer].Visible = True
End If

End Sub

The msgbox tells me that I'm on page 1 - but the controls are still visible (on a 1 page report). However, on a 2 page report it works correctly.
Any ideas why this would be happening?

Thanks in advance,
TS
 
you can also simplify your code

Code:
Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)

     Me.[lbl_ClientName_Footer].Visible = Me.Page <> 1
     Me.[txt_ClientName_Footer].Visible =  Me.Page <> 1


End Sub

not tested but pretty sure if you can associate the label with the textbox, you only need

Me.[txt_ClientName_Footer].Visible = Me.Page <> 1

since hiding the textbox will also hide the associated label
 
Thanks Pat! Works perfectly now!
 
As @Pat Hartman says, reports can be funny things. If you preview a report and then print it, that can also change page counts as they might not be reset for the print process, depending how you actually manage the page counts.
 

Users who are viewing this thread

Back
Top Bottom