Hide control on open

AnnPhil

Registered User.
Local time
Today, 19:38
Joined
Dec 18, 2001
Messages
246
I have a macro that opens a form but i would also what the macro to hide a control on the form when opened, i think this is possible but i can't remember how to set the value of a control to not visible using a macro.
 
It is a SetValue action

Item [forms]![FormName]![ControlOrLabelName].Visible
Expression No
 
Did that but it is still visible on open, don't i need to say something to make it not visible?

tried [forms]![FormName]![ControlOrLabelName].Visible=False but that didn't work.
 
Are you really talking about a macro (like Mike is talking about) or are you talking about VBA code? Your example:
Code:
[forms]![FormName]![ControlOrLabelName].Visible=False
looks more like code than macro.
 
Did that but it is still visible on open, don't i need to say something to make it not visible?

tried [forms]![FormName]![ControlOrLabelName].Visible=False but that didn't work.

The "No" in the Expression box does that and Yes makes visible

"False" as Bob says is code but False will work in SetValue macro action, at least in A2003.

In a macro the .Visble will automatically turn into .[Visible]

Code looks like

Forms!FormName!ControlOrLabelName.Visible = False

Is it possible that you have another macro or piece of code that runs (like OnCurrent) that makes the control visble or perhaps you referred to the wrong control in the macro.
 
If the control needs to be invisible when the form is opened, then set its visible property to false in design mode.
 
I agree - then use code to reveal it if and when appropriate.

No definite answer for that.

If a control is to have its Visible property changed then the default position will depend on the form's use for that person.

But at this stage that is irrelevant because AnnPhil is not not able to make the control invisble and one would assume the same problem would prevent her from making it visible.
 
No definite answer for that.

If a control is to have its Visible property changed then the default position will depend on the form's use for that person.
Yes - the default position clearly is for it to be invisible here - because the OP wants it to disappear when the form is loaded.


But at this stage that is irrelevant because AnnPhil is not not able to make the control invisble and one would assume the same problem would prevent her from making it visible.
Could it perhaps just be a typo in the reference to the object somewhere? - that should normally raise an error, but it's not uncommon for errors/warnings to be turned off inside a macro...)
 
Could it perhaps just be a typo in the reference to the object somewhere? - that should normally raise an error, but it's not uncommon for errors/warnings to be turned off inside a macro...)

If the control or label refered to in the macro does not exist you get a warning box along the lines of This is not a Visual Basic object etc

My guess is she is simply referring to the wrong control and perhaps it is not obvious that the wrong control has been made invisible.
 
OK it was a typo, sorry. Thanks so much for all your help, the form works great now. I use the form in two different instances and wanted to hide a few controls in one but not the other so now it works on both! I usually write this in code but for reason i wont go into i needed to put it in an existing macro and just didn't remember how to do it.,

thanks again...
 
If the control or label refered to in the macro does not exist you get a warning box along the lines of This is not a Visual Basic object etc
Not (as I said) if errors have been turned off. I tested this.
 

Users who are viewing this thread

Back
Top Bottom