Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Formating

Status
Not open for further replies.

jacque427

Technical User
Nov 5, 2003
122
US
I have the following code in a report to "hide" blank fields.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If Ctrl.ControlType = acTextBox Then
If IsNull(Ctrl.Value) Then Ctrl.Visible = False Else Ctrl.Visible = True
End If
Next Ctrl

End Sub


It works wonderfully, what I am wondering is can the rest of the report move up to fill in the area left blank?


 
Hi Duane,

I put >"" as I tried things like <> Null or = Null and it didn't work properly. I have tried this expression in the database above and it works fine, hence the comments re the vertical gaps between fields still showing (any thoughts on this btw).

I would expect that actually having something in the field would qualify as being > "", but null wouldn't.

Graham
(Still learning)

 
The issue is that the field will either store text or will be null. It is difficult to even store a zero length string in a field.

You can never reliably test for Null with "=" or "<" or any other operator. My solution simply concatenates with a "+" rather than "&" since
"This String" + Null
will result in Null.

If you need to compare or test for Null, the proper method is to use something like:
=IIf(IsNull([expression]), "value if null", "value if not Null")

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top