If Empty/null field, hide label (?)

  • Thread starter Thread starter James
  • Start date Start date
J

James

I'm trying what I thought was a very simple task, to hide a report label if
a certain text box/data field is null.

The following does nothing when the report is run.
Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)
If Me!txtServOrdered = Null Then
Me!labServOrd.Visible = False
End If
If Me!txtServRendered = Null Then
Me!labServRend.Visible = False
End If
End Sub

Sould I try to test the actual field values rather than the contents of a
text box?

My data is from a query: qryInvoices

Any suggestions appreciated
 
James said:
I'm trying what I thought was a very simple task, to hide a report label
if a certain text box/data field is null.

The following does nothing when the report is run.
Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)
If Me!txtServOrdered = Null Then
Me!labServOrd.Visible = False
End If
If Me!txtServRendered = Null Then
Me!labServRend.Visible = False
End If
End Sub

Sould I try to test the actual field values rather than the contents of a
text box?

My data is from a query: qryInvoices

Any suggestions appreciated
Resolved using:

If IsNull(Me!txtServOrdered) Then
Me!labServOrd.Visible = False
End If
If IsNull(Me!txtServRendered) Then
Me!labServRend.Visible = False
End If
 
Might I suggest you use the following to show or hide the label as appropriate.

Me.labServOrd.Visible = Not(IsNull(Me.txtServOrdered))
Me.labServRend.Visible = Not(IsNull(Me.txtServRendered))

Right now the code hides the labels, but if a later record has a value in the
relevant field the label's visible property is not set to true.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
Back
Top