Hide report section

L

Leslie Isaacs

Hello All

I have a report where the record sourse is a query that returns a single
record. Normally the report prints on two pages, because I have a pagbreak
controll half way down the detail section (this is necessary because of the
particular requirement of the report's layout). In some cases, however, the
second page is not required: this is when the value of a particular textbox
('txtFound') in the detail section is >0. In these cases only the first page
is required - without a blank second page.

I realise I could do this by setting the data source for all the '2nd-page'
controlls to be empty (null?) if the value of 'txtFound' is not >0, and then
setting the CanShrink property to Yes, but this doesn't seem to be the right
way to do it. I know also that I could put all the '2nd-page' controlls on a
separate report, but for this purpose that wouldn't work because the reports
is in fact one of many that is generated and emailed as a bach and the 2
seperate reports would get lost from each other.

So, is it possible to hide all the controls after the PageBreak IF the value
of txtFound is not >0? Perhaps by putting them all in the report footer and
hiding the section if the value of txtFound is not >0?

Hope someone can help.

Many thanks
Les
 
M

Marshall Barton

Leslie said:
I have a report where the record sourse is a query that returns a single
record. Normally the report prints on two pages, because I have a pagbreak
controll half way down the detail section (this is necessary because of the
particular requirement of the report's layout). In some cases, however, the
second page is not required: this is when the value of a particular textbox
('txtFound') in the detail section is >0. In these cases only the first page
is required - without a blank second page.

I realise I could do this by setting the data source for all the '2nd-page'
controlls to be empty (null?) if the value of 'txtFound' is not >0, and then
setting the CanShrink property to Yes, but this doesn't seem to be the right
way to do it. I know also that I could put all the '2nd-page' controlls on a
separate report, but for this purpose that wouldn't work because the reports
is in fact one of many that is generated and emailed as a bach and the 2
seperate reports would get lost from each other.

So, is it possible to hide all the controls after the PageBreak IF the value
of txtFound is not >0? Perhaps by putting them all in the report footer and
hiding the section if the value of txtFound is not >0?

Add a group (View menu - Sorting and Grouping) using a
constant expression like =1 and set the group to have a
footer section.

Then drag all the second page controls to the new group
footer section. Set the group footer's ForceNewPage
property to Before Section (and get rid of the page break
control).

You can then hide the entire group footer section by using a
line of code in the detail section's Format event:
Me.Section(6).Visible = (txtFound <= 0)
 
L

Leslie Isaacs

Marshall

Many thanks for your reply. Just a couple of things:
Should the group actually be "=1" or just "1" (obviously without the
apostrophies)?
Also, I assume that Me.Section(6) refers to the new group footer - but if I
alsready have some other group footers how will access know which group
footer to hide? What is Me.Section(1), and Me.Section(2), etc?

Thanks again for the help.
Les
 
M

Marshall Barton

Leslie said:
Many thanks for your reply. Just a couple of things:
Should the group actually be "=1" or just "1" (obviously without the
apostrophies)?
Also, I assume that Me.Section(6) refers to the new group footer - but if I
alsready have some other group footers how will access know which group
footer to hide? What is Me.Section(1), and Me.Section(2), etc?


Use any constant. =1 is simple, but you could use
="Second Page"
if you prefer.

If you have other Sorting/Grouping entries, put this one at
the bottom of the list.

Look up Section Property in VBA Help for details about
section numbering. You can also use the name of the section
instead of .Section(n), e.g. Me.GroupFooter4 (a more
meaningful name would be easier to follow).
 

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