Error With Code

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

Guest

I have a form which generates this reprt and someone in this forum helped me
with this code to suppress the printing of empty field and their labels:

Dim ctl As Control
For Each ctl In Me.Detail.Controls
Select Case Left(ctl.Name, 3)
Case "txt", "cbo", "mem"
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

It was working fine but now I'm getting this error:

Run-time error '2427':
You entered an expression that has no value.

And the line that get highlighted is the one that says:" If
IsNull(ctl.Value) then".

The funny thing is that this report is also called by a different form and
it works fine. Any ideas if there is a problem with this code? Thanks.
ck
 
What is the ctl.Name when this happens? I expect that you have a control
with no Control Source property that begins with txt, cbo or mem.
 
Back
Top