How suppress detail line on report if condition met

S

SteveL

I want to suppress the printing on a detail line on a
report IF a certain condition is met. In other words, I
have a calculated field on the detail line. If the value
of that calculated field is <0 then I want to suppress
the entire line from printing.

Anybody know how?
 
R

Rick Brandt

SteveL said:
I want to suppress the printing on a detail line on a
report IF a certain condition is met. In other words, I
have a calculated field on the detail line. If the value
of that calculated field is <0 then I want to suppress
the entire line from printing.

Anybody know how?

In the Format event of the section...

If Me![SomeControlName] < 0 Then Cancel = True
 
J

Joshua A. Booker

Steve,

The easiest way to to keep records off a report is to do so in the criteria
of the report's recordset.

I assume you need to supress printing becauses the criteria solution won't
work for you. For example, maybe you need the records to contribute to the
totals on the report but you don't want them to print.(?)

To do this you set the PrintSection property of the report object to false
in the Format Event of the Detail Section.(or of another section if you need
to supress a header or footer)

Like This:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [Calculation] <0 then
Me.PrintSection = False
End If
End Sub


Where [Calculation] is the condition to be met. Also, sometimes you can't
rely on a calulated control on a report in the reports code due to the
timing of events so it's best to do the actual calc in the code or in the
query rather than on the report in this case.

HTH,
Josh
 

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