How can I reset visibilty of a control?

D

Dave

Under certain conditions, I want a form to open with a particular control
hidden (i.e., not visible)

Me.cmdButton.visible = False

Under other conditions, I want this control to be visible. The default
condition should be visibile =true

I put code in my Form_Open procedure to test the conditions. However, once
the invisible condition is met, I can't seem to make the control visible
again.

I tried adding Me.cmdButton.visible = true to the Form_Unload and
form_close events but this does not work. Once the conditions for
invisibility have been met, the form always opens up with the control
visibility set to false.

What is the proper way to reset visbility in this case?
 
M

Marshall Barton

Dave said:
Under certain conditions, I want a form to open with a particular control
hidden (i.e., not visible)

Me.cmdButton.visible = False

Under other conditions, I want this control to be visible. The default
condition should be visibile =true

I put code in my Form_Open procedure to test the conditions. However, once
the invisible condition is met, I can't seem to make the control visible
again.

I tried adding Me.cmdButton.visible = true to the Form_Unload and
form_close events but this does not work. Once the conditions for
invisibility have been met, the form always opens up with the control
visibility set to false.

What is the proper way to reset visbility in this case?


Depends on what the"certain conditions" are.

Typically, this is done in the form's Current event so the
control's visibility is adjusted as you navigate from one
record to another. If the control's visibility is
determined independently of the data in the records (e.g. a
user's name), then the Load (or Open) event is appropriate.

Regardless of where you set it, you should make the
visibility setting for both cases. For example:

If certainconditions Then
Me.cmdButton.visible = False
Else
Me.cmdButton.visible = True
End If

Or, if the condition is a simple True/False expression, that
can be simplified to:

Me.cmdButton.visible = Not certainconditions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top