Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditionally Shrink Footer/Header 1

Status
Not open for further replies.

mkrauss

Technical User
Sep 1, 2005
9
US
I have three groupings each with a header and two footers. The footers and headers contain text boxes that will never be null. For example, the footers contain sumations. The problem is that I want the headers and footers to not print and shrink to zero for two of the three groupings. I've been able to get them to not print and to shrink. However this results in the headers and footers for all three grouping to disappear. It seems I've run into an all or nothing situation. Here's the code:

Private Sub GroupFooter0_Format(Cancel As Integer, PrintCount As Integer)

If Me!
Code:
 = "N/A" Then
        Me.PrintSection = False
        Me.Text1.Height = 0
        Me.GroupFooter0.Height = 0  
    End If

End Sub

I think the problem is how do I get everything to show if Me![Code] doesn't equal "N/A".  I tried returning the height to normal using the else statement, but it didn't work.

Thanks in advance,

Mike
 
Try this:
Code:
Private Sub GroupFooter0_Format(Cancel As Integer, PrintCount As Integer)
    Cancel = Me![Code] = "N/A"
End Sub



Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks Duane. This worked perfectly.

Mike
 
I've tried to get an answer similar to the problem above, Dhookom you got one more in your expertise bag of tricks?

I have a Page Header that I would like to cancel if there are no Detail records.

Now, that might sound strange, but I have a very extensive report footer that often makes the report go to 2 pages but there aren't any detail records and the Page Header looks silly with no details under it.

Any suggestions,
Thanx
 
You can try a line of code in the On Format of the Page Header section:
Code:
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
    Cancel = Not Me.HasData
End Sub

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Still doesn't work. Any other suggestions?
How about you tell us why you think it doesn't work?

Before I posted the answer, I created a report that had a record source that didn't return any records. I made sure my report had a Page Header section and tested the code. It worked for me.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
The report has records, its the 2nd page that doesn't have any records.

This could be the case if you had records and then a natural page break occurred because of a lengthy report footer or if you had a manual page break for the report footer set in the section as break "before".
 
I misunderstood "I have a Page Header that I would like to cancel if there are no Detail records" as meaning there were not detail records in the report, not the page.

Consider using a group header rather than a page header.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Interesting, I can see how that might work in certain situations or even possibly jimmy rigging it by creating a fake group header by creating a field with just one piece of data in it and then not using the field in the header.

Its not critical, I like to copy pieces of code you guys put out and then save them in a file to later access for situtations never covered in any book.

Some of you MVPs like Dhookom and PHV ought to get together and write a book like the Access Cookbook (which I need to buy!). There's tons of stituations that are never covered in any book....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top