Results 1 to 2 of 2
2005-01-12, 21:29 #1
- Join Date
- Jun 2002
- Michigan City, Indiana, USA
- 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.
2005-01-12, 21:41 #2
- Join Date
- Mar 2002
- Thanked 25 Times in 25 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:
Private Sub Details_Format(Cancel As Integer, FormatCount As Integer)
Me.TIrr.Visible = Not IsNull(Me.TIrr)
- Switch back to Access (Alt+F11)