Hiding a field in Page Header based on a variable (1 Viewer)

HGMonaro

Registered User.
Local time
Today, 15:25
Joined
Apr 22, 2010
Messages
61
Hi,

Searched and search but can't find anything like this.

I have a report where I number pages based on the Store (muliple stores in report but page numbering resets when Store changes) I do this by manipulating the page number field on the report by code in the report sections to reset it and to increment it. Works beatifully :)

Code:
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
    Me!PageNum = 0
End Sub
 
Private Sub PageFooter_Format(Cancel As Integer, FormatCount As Integer)
    Me!PageNum = Me!PageNum + 1
End Sub
 
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
    Me!PageNum = 0
End Sub


The report has a Page Header with various fields and labels and that's been fine however I've had a request to hide a field on subsequent pages (i.e. print it on the 1st page of each store then hide it).

So I added the following code to various sections, but can't get it to work correctly. The fields (label and text box) appear on Page 1 for the first store then get hidden but never return even though when I step through the code it is functioning 'correctly'. The GroupHeader code is performed but the fields don't get displayed on the report. I think is isn't re-painting that section but adding code to the Paint event does nothing, and in fact doesn't actually get run, so not sure when that event is triggered.

Code:
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
   Me!PageNum = 0
   lblMemberNo.Visible = True
   MemberNo.Visible = True
End Sub
 
Private Sub PageFooter_Format(Cancel As Integer, FormatCount As Integer)
   Me!PageNum = Me!PageNum + 1
End Sub
 
Private Sub PageHeader_Format(Cancel As Integer, FormatCount As Integer)
If Me!PageNum < 1 Then
    lblMemberNo.Visible = True
    MemberNo.Visible = True
Else
    lblMemberNo.Visible = False
    MemberNo.Visible = False
End If
End Sub
 
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
   Me!PageNum = 0
End Sub


Any ideas?
 

highandwild

Registered User.
Local time
Today, 06:25
Joined
Oct 30, 2009
Messages
435
I am not a reports expert but I often set the query up to contain all of the data needed for the report.

Instead of having to hide the control on the report just have a column in the query that has a value / is blank where appropriate. The control on the report will always be visible.

Doing it this way I can test that the query works before creating the report.

A purist may suggest a better way.
 

HGMonaro

Registered User.
Local time
Today, 15:25
Joined
Apr 22, 2010
Messages
61
interesting concept. I would need to process the table but that's possible. thanks for the suggestion.
 

HGMonaro

Registered User.
Local time
Today, 15:25
Joined
Apr 22, 2010
Messages
61
back again... got it working. Not very elegant but at this point in time... I don't care! :)
 

Users who are viewing this thread

Top Bottom