Skip to content

Suppressing Printing of a Control or a Record

How to suppress printing of a record or a control on a report.

Q: Luis Pelaez is looking for a way to suppress printing of a record on a report if the Balance Due field is zero.

A: If you wish to just suppress printing of one or more controls, code like the following will do the job (you should also set the Detail section’s CanShrink property to Yes). If you want to exclude the entire record, then this is better done in a query – just use the criterion >0 on the Balance Due field, and use that query (or SQL statement) as the report’s record source.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

 

On Error GoTo ErrorHandler

 

If Nz(Me![Salary]) = 0 Then

   Me![txtSalary].Visible = False

Else

   Me![txtSalary].Visible = True

End If

 

ErrorHandlerExit:

   Exit Sub

ErrorHandler:

   MsgBox “Error No: ” & Err.Number & “; Description: ” & _

      Err.Description Resume ErrorHandlerExit

 

End Sub

About this author

Office 2024 - all you need to know. Facts & prices for the new Microsoft Office. Do you need it?

Microsoft Office upcoming support end date checklist.