Controls Visible

access7

Registered User.
Local time
Today, 09:37
Joined
Mar 15, 2011
Messages
172
Hello

Hoping this is a nice quick one... is there anyway to make ALL controls visible on a form at the push of a button... I have quite a few controls all grouped together that start off when the form is opened as visible = False but on click of a button I want them to be visible... I am trying to avoid having to name each individual control in the code?

Thanks
 
You can hide the section or loop through the controls and hide each.
 
I have tried 'grouping the controls' together (in an object frame or option group) but I don't know how to put the controls in the option group or frame in order to get them into one section?
Failing that I will as you say create a loop for the controls with an array, was just trying to avoid having to do that...
I thought there was a way I could get the controls to 'group together' so I could just as you say hide that particular part...
Any ideas??
 
You can put the controls in a tab control for example.
 
Attached is a small demo file that uses a user defined function to read values saved in the "Tag" property of various controls to show or hide, enable or disable, lock or unlock, etc. and control that has specific values in their "Tag" property.

You can check out out how this works by trying the demo and then if you want to implement this type of control management in your application, you can simple import the "modManageControls" module into your application and then use the following line of code to manage your controls:
Code:
SetStatusOfControls "NameOfYourForm", StatusVal

Just change the "NameOfYourFomr" to the actual name of your form and provide true or false for the "StatusVal" parameter.
 

Attachments

Thanks vbaInet; I perhaps should have mentioned, the controls are already on a page of a tab control....
Thanks
 
Thank you - that's perfect! And could come in very useful for other things in the future. All very good learning! I did have to alter the code a little though as the variable was called
'Public Function SetStatusOfControls(FormName As String, Status As Boolean)'
but later on it was
'On Error GoTo Err_SetControlsStatus'

Other than that it has done exactly what I needed (and saved me going bald from pulling my hair out)!
Many thanks again :-)
 
Thanks vbaInet; I perhaps should have mentioned, the controls are already on a page of a tab control....
Thanks
You could have simply hidden the page:
Code:
Me.TabControl.Pages("PageName").Visible = False
 
Thanks, I will bear that in mind for any future things but it would not have worked in this case as it is only some of the controls on the tab control page, not all of them. Thanks though for your reply.
 
Ok, if you're not going to to be looping through the controls very often then the method from Mr. B will suffice.

Happy developing!
 

Users who are viewing this thread

Back
Top Bottom