Hide A Line on A Report

D

DS

I have a Line in a Group Footer.
I want to print the line when the field PDPrepGroupID =0
if it's not 0 I don't want to print it. Heres what I have so far.

Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As Integer)
If Me.PDPrepGroupID = 0 Then
Me.PrintSection = False
Me.NextRecord = True
End If
End Sub

I have this in the OnPrint Property of the Group Footer.
I keep getting an Error Message that PDPrepGroupID is not found.

Any Help Appreciated.
Thanks
DS
 
A

Allen Browne

Is the a *control* named PDPrepGroupID on the report?
If not add a text box with that name.
Set its Visible propety to No if you wish.

Because of the way Access optimises the report, sometimes it doesn't bother
to fetch the data for a field if it is not actually used anywhere on the
report. Adding a text box solves the problem, since it then fetches the data
for the field.

That will solve your immediate problem, but it will create several others:
a) You need to use the Format event rather than the Print event of the
section to suppress it.

b) Did you want to set the MoveLayout property as well?

c) You have only handled the case where the value is zero. Did you want to
set the properties when PDPrepGroupID is not zero? Or when it is Null?

d) Suppressing/repeating sections like this gives unreliable results if you
do not print the entire report. The code fires only for the pages that are
actually previewed/printed, so if you preview the report and then through
File | Print just print page 5, it will print the wrong stuff (compared to
if you print the whole report.)

e) Suppressing/repeating sections also messes up the page numbering. If you
have a text box showing:
=[Page] of [Pages]
it is likely to print things like "Page 5 of 4".
 
D

DS

Allen said:
Is the a *control* named PDPrepGroupID on the report?
If not add a text box with that name.
Set its Visible propety to No if you wish.

Because of the way Access optimises the report, sometimes it doesn't bother
to fetch the data for a field if it is not actually used anywhere on the
report. Adding a text box solves the problem, since it then fetches the data
for the field.
OK Thats Solved.
That will solve your immediate problem, but it will create several others:
a) You need to use the Format event rather than the Print event of the
section to suppress it.
Also Solved
b) Did you want to set the MoveLayout property as well?
What does this do?
c) You have only handled the case where the value is zero. Did you want to
set the properties when PDPrepGroupID is not zero? Or when it is Null?
I only need the 0 if it's anything else then you would not see it or
print it.
d) Suppressing/repeating sections like this gives unreliable results if you
do not print the entire report. The code fires only for the pages that are
actually previewed/printed, so if you preview the report and then through
File | Print just print page 5, it will print the wrong stuff (compared to
if you print the whole report.)
Its a report on a continous roll of paper so page numbers are not an issue.
e) Suppressing/repeating sections also messes up the page numbering. If you
have a text box showing:
=[Page] of [Pages]
it is likely to print things like "Page 5 of 4". No page numbers
Thanks Allen, this gave me a clearer sense of whats happening, I'm not
sure what the move layout does though?
Thnaks
DS
 
M

Marshall Barton

DS said:
I have a Line in a Group Footer.
I want to print the line when the field PDPrepGroupID =0
if it's not 0 I don't want to print it. Heres what I have so far.

Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As Integer)
If Me.PDPrepGroupID = 0 Then
Me.PrintSection = False
Me.NextRecord = True
End If
End Sub

I have this in the OnPrint Property of the Group Footer.
I keep getting an Error Message that PDPrepGroupID is not found.


From your code it looks like you want the section to be
blank (using the same amount of space as when the value is
not zero). To suppress the entire section, you should also
use:
Me.MoveLayout = False

But if you do want to suppress the entire section, it would
be better to use either:

Private Sub GroupFooter0_Format(Cancel As Integer,
FormatCount As Integer)
Cancel = (Me.PDPrepGroupID = 0)
End Sub

Or

Private Sub GroupFooter0_Format(Cancel As Integer,
FormatCount As Integer)
GroupFooter0.Visible = (Me.PDPrepGroupID <> 0)
End Sub

In you only want to suppress part of the section, then use a
text box with an expression that results in wither Null or
"" and set CanShrink for both the text box and the section
to Yes.
 
A

Allen Browne

Open the code window, and go to Help for details on the MoveLayout method of
the Report object.

Basically this property determines whether Access prints space for the
repeated record. Setting MoveLayout and PrintSection to No suppresses the
record and its space. Setting NextRecord to No and MoveLayout to Yes adds
one detail-section height below the record, and so on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

DS said:
Allen said:
Is the a *control* named PDPrepGroupID on the report?
If not add a text box with that name.
Set its Visible propety to No if you wish.

Because of the way Access optimises the report, sometimes it doesn't
bother to fetch the data for a field if it is not actually used anywhere
on the report. Adding a text box solves the problem, since it then
fetches the data for the field.
OK Thats Solved.
That will solve your immediate problem, but it will create several
others:
a) You need to use the Format event rather than the Print event of the
section to suppress it.
Also Solved
b) Did you want to set the MoveLayout property as well?
What does this do?
c) You have only handled the case where the value is zero. Did you want
to set the properties when PDPrepGroupID is not zero? Or when it is Null?
I only need the 0 if it's anything else then you would not see it or print
it.
d) Suppressing/repeating sections like this gives unreliable results if
you do not print the entire report. The code fires only for the pages
that are actually previewed/printed, so if you preview the report and
then through File | Print just print page 5, it will print the wrong
stuff (compared to if you print the whole report.)
Its a report on a continous roll of paper so page numbers are not an
issue.
e) Suppressing/repeating sections also messes up the page numbering. If
you have a text box showing:
=[Page] of [Pages]
it is likely to print things like "Page 5 of 4". No page numbers
Thanks Allen, this gave me a clearer sense of whats happening, I'm not
sure what the move layout does though?
Thnaks
DS
 

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