Suppressing Blank Fields & Labels

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I did a search and found several solutions provided for this common question.
However, I noted that all of them require me to place codes in each of the
fields and it gets a little tedious when I have 15-20 fields or more.

Is there some code I can apply globally to the report to just say if there
is any field anywhere in the report that is null, just don't display the damn
label as well (who wants a report with a label hanging without any
information anyway?).

Thanks.
ck
 
This is untested aircode and is meant simply as an idea that might be worth
trying. It assumes that textbox names have a prefix of txt. If I recall, if
you turn a text box invisible, any "associated" label will automatically go
with it. The check for "cbo" probably isn't necessary unless you use
comboboxes on reports for some reason :-) I left it in simply as a
conceptual hint of other possible uses.

You could place similar code in each section (Headers, Footers). I doubt you
could do it just one time for the report as a whole because the timing of
when things get Formatted wouldn't allow it.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim ctl As Control

For Each ctl In Me.Detail.Controls
Select Case Left(ctl.Name, 3)
Case "txt", "cbo"
If IsNull(ctl.Value) Then
ctl.Visible = False
Else
ctl.Visible = True
End If
Case Else
'Ignore: wrong type of control
End Select
Next ctl
End Sub

--

HTH,
George Nicholson

Remove 'Junk' from return address.
 
Back
Top