View Full Version : Blank field problem?


bissonette
06-30-2004, 09:58 AM
I am using the following code for a blank field problems i was having and I get a run time error and the debugger goes to line "If IsNull(ctl.Value) Then" and says something is wrong with it. Any suggestions????

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim ctl As Control
Dim blnNoPrint As Boolean
For Each ctl In Me.Controls
If ctl.Tag = "CheckIt" Then
If IsNull(ctl.Value) Then
blnNoPrint = True
Exit For
End If
End If
Next

If blnNoPrint Then
Me.MoveLayout = False
Me.PrintSection = False
Else
Me.PrintSection = True
End If
End Sub

PaddyIrishMan
07-01-2004, 12:35 AM
Hi,
Maybe some of your controls don't support the 'Value' method?
If you are looking at validating text boxes then decare ctl as type textbox.

Regards,
Patrick

Rich
07-01-2004, 12:41 AM
Why not just use the CanGrow/Shrink on the property sheet?

bissonette
07-01-2004, 05:26 AM
I cant use the shrink/grow option because it leaves the lable behind. Is there a way to change that?

Rich
07-01-2004, 05:39 AM
re-attach the label to the control

bissonette
07-01-2004, 07:30 AM
But if i re-attach the label to the control it will print on every record whether it has a data field or not.

____________
Date:
12/12/03
____________

Date:

____________

Date:
2/23/04
____________

And it will look like this. Is there a way to make a label attach if there is only data????

Rich
07-01-2004, 09:18 AM
Here's another option
Dim ctrl As Control
For Each ctrl In Me.Controls
If IsNull(ctrl) Then
ctrl.Visible = False
Else
ctrl.Visible = True
End If
Next
Set ctrl = Nothing
End Sub