Results 1 to 2 of 2
  • Thread Tools
  1. Lounger
    Join Date
    Jun 2002
    Location
    Michigan City, Indiana, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print control on report only if not null (2003)

    I have a form that staff fill out when a student takes a test. The results of this form go into a report. One of my controls is TIrr (testing irregularities). I would like this control to only print on the report if this control has something in it, i.e., is not null. I am very inexperienced with code so full code would be very helpful. Currently, I have a button on my form that brings up the report and automatically prints it. Any help would be much appreciated.

    Jodi

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 13 Times in 13 Posts

    Re: Print control on report only if not null (2003)

    If you have a series of text boxes below each other (on a report), you can set the Can Shrink property of a text box and of the section containing it (probably the Detail section) to Yes. If the value of the text box is Null, it will not be displayed or printed, and the controls below it will move up so that no blank space is left.

    This doesn't help if your controls are organized differently. You can use code in the On Format event of the section containing the control (probably the Detail section) to hide it if it is Null:
    - Open the report in design view.
    - Click on the horizontal gray bar at the top of the section containing the control.
    - Activate the Event tab of the Properties window.
    - Click in the On Format box.
    - Select [Event Procedure] from the dropdown list.
    - Click the ... to the right of the dropdown arrow.
    - The Visual Basic Editor will be activated, and the insertion point will be in a blank line between the first and last line of the event procedure that has been created for you.
    - Press tab, and type <code>Me.TIrr.Visible = Not IsNull(Me.TIrr)</code> where TIrr is the name of the text box.
    - The procedure should now look like this:
    <code>
    Private Sub Details_Format(Cancel As Integer, FormatCount As Integer)
    Me.TIrr.Visible = Not IsNull(Me.TIrr)
    End Sub
    </code>
    - Switch back to Access (Alt+F11)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •