How to conditionally hide/unhide object?

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

Guest

Hi everyone,

I have a bound object 1 and another bound object 2 in a form. I was hoping
to hide object 2 when object 1 is empty, and unhide it when object 1 isn't
empty.

Nikos has kindly suggested the following lines and I've amended them
slightly to suit my application, but a type mismatch error occurs when I run
the code. I wonder if it is because different extraneous character (such as "
and #) should be used for bound object? Could someone please educate me a bit
more?
Form Current -> so it fires when the form opens, and when moving from
record to record
Bound object 1 Before Update -> so it fires if when the user changes it
The code (the same in both events) would look something like:
vShow = Not (Me.BoundObject1 = "" Or IsNull(Me.BoundObject1))
' the line above returns a type mismatch error
Me.BoundObject2.Visible = vShow
Me.BoundObject1Label.Visible = vShow


Regards,
Sam
 
Thanks for your responce, Dan.

Could you please explain a bit more on how Boolean should be used in my
situation?

Because similar lines work OK in a text box control. For example, I have
this command button 1 in the same form invisible when a certain textbox 1 is
empty, and visible otherwise. The lines (in both Form's Current event and
Textbox1's BeforeUpdate event) look something like this:

' Hide cmbButton1 when Textbox1 is blank, unhide otherwise
vShow1 = Not (Me.Textbox1 = "" Or IsNull (Me.Textbox1)
Me.cmbButton1.Visible = vShow1

Regards,
Sam
 
Back
Top