"You have entered an expression that has no value"

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

Guest

I am trying to write a simple command. If the field "time test" is 0, I don't want a lable to show up. Unfortunately, I keeping getting the error "you have entered an expression that has no value". The "tiem test" control is a numeric text box. Following is my code:

Private Sub Report_Open(Cancel As Integer)
If TimeTest = 0 Then
LblTotalDue.Visible = False
End If
End Sub

Thanks in advance!
 
I am trying to write a simple command. If the field "time test" is 0, I don't want a lable to show up. Unfortunately, I keeping getting the error "you have entered an expression that has no value". The "tiem test" control is a numeric text box. Following is my code:

Private Sub Report_Open(Cancel As Integer)
If TimeTest = 0 Then
LblTotalDue.Visible = False
End If
End Sub

Thanks in advance!

You are placing your code in the wrong event.
If the label is in the report detail section, place the code in the
Detail Format event.
As written, your code will permanently hide the label once it's made
not visible, as you have no code to make it visible again when the
criteria is not met.

Try it this way:

Private Sub Detail_Format(etc....)
If TimeTest = 0 Then
LblTotalDue.Visible = False
Else
LblTotalDue.Visible = True
End If
End Sub

An easier method would be, simply:

LblTotalDue.Visible = Not TimeTest = 0
 
Fred, thank you so much. This worked.

fredg said:
You are placing your code in the wrong event.
If the label is in the report detail section, place the code in the
Detail Format event.
As written, your code will permanently hide the label once it's made
not visible, as you have no code to make it visible again when the
criteria is not met.

Try it this way:

Private Sub Detail_Format(etc....)
If TimeTest = 0 Then
LblTotalDue.Visible = False
Else
LblTotalDue.Visible = True
End If
End Sub

An easier method would be, simply:

LblTotalDue.Visible = Not TimeTest = 0
 
Back
Top