Hiding A Label Based On A Text Box Value

  • Thread starter Thread starter Jim Mac Millan
  • Start date Start date
J

Jim Mac Millan

Hello,

I am putting together a report and would like the "label" (Label88)
visible only when data is in the "text box" (Style_Name). I have placed the
code below.

- - - - - - - - - - -
Private Sub Report_Open(Cancel As Integer)
If Me.Style_Name.Data = "" Then Label88.Visible = False Else
Label88.Visible = True
End Sub
- - - - - - - - - - -

I get a Run-time error that the Object doesn't support this property or
method with the following line highlited (If Me.Style_Name.Data = "" Then)

Any Ideas?
Thanks
Jim M M
 
An alternate (and I think easier) approach to using code
would be to simply delete the Label88 control and replace
it with an unbound text box. Set the new text box's
Control Source to

=IIf(Not IsNull([Style_Name]),"Style:")


As for your error message, I think it has to do with when
the code is run. You have the code set up to execute in
the Report Open event, and to over simplify things a bit,
the Style_Name control doesn't exist yet.

Your logic is sound, so you could try your code in the
Detail section's On Format event. I think you would need
to adjust the syntax in your assignment statements, though
(Me.Label88.Visible = False).

I usually use the textbox method outlined above, as other
people that have to work with the reports tend to be able
to deal with it much better than trying to deal with VB
code. Your mileage may vary...

Rob
 
Rob,

A big THANK YOU!

I used your example, it works perfectly.

Incidentally I tried making the appropriate addition to my code and
moved it to the Detail section's On Format event. Unfortunately I receive
the same error.

Again, Thanks for the help.
Jim MM


Rob said:
An alternate (and I think easier) approach to using code
would be to simply delete the Label88 control and replace
it with an unbound text box. Set the new text box's
Control Source to

=IIf(Not IsNull([Style_Name]),"Style:")


As for your error message, I think it has to do with when
the code is run. You have the code set up to execute in
the Report Open event, and to over simplify things a bit,
the Style_Name control doesn't exist yet.

Your logic is sound, so you could try your code in the
Detail section's On Format event. I think you would need
to adjust the syntax in your assignment statements, though
(Me.Label88.Visible = False).

I usually use the textbox method outlined above, as other
people that have to work with the reports tend to be able
to deal with it much better than trying to deal with VB
code. Your mileage may vary...

Rob

-----Original Message-----
Hello,

I am putting together a report and would like the "label" (Label88)
visible only when data is in the "text box" (Style_Name). I have placed the
code below.

- - - - - - - - - - -
Private Sub Report_Open(Cancel As Integer)
If Me.Style_Name.Data = "" Then Label88.Visible = False Else
Label88.Visible = True
End Sub
- - - - - - - - - - -

I get a Run-time error that the Object doesn't support this property or
method with the following line highlited (If Me.Style_Name.Data = "" Then)

Any Ideas?
Thanks
Jim M M


.
 
Back
Top