Page 1 of 1

Access Hide all subforms

Posted: 13 Apr 2009, 17:06
by Mclaren
OK, so i have a main form with several subforms on. No data is linked. I have a Command button for each subform which when clicked must either inhide or hide a specific subform. I want each form to only show if i click its corresponding command button. Currently i have to fist click to show a subform then click same command button again to hide said subform before i click another button for another form.

I am looking for a function that can be called from each buttons OnClick event to first check and see if any subforms are visible and if so to hide them beor opening the subform i am currently selecting. I have found many for next loops for controls on the net but none for Subforms. the code i have tried tends to want to close all forms that are visible and not just the subforms that are on the current form.

another solution would be to have the button open a pop up form set to modal, but i want each form to open to a specific size and position on the screen. this i have not managed to do yet.

please can some one help. a solotuion to my first option would be great.

Re: Access Hide all subforms

Posted: 13 Apr 2009, 17:16
by Tribble
I will have to think about the rest but a quick fix for the size and position is to use the macros. You use a macro to open the sub forms. You can position each form and control the size. I am sure you can do it in VB too but I cannot give you the code for that offhand.

Re: Access Hide all subforms

Posted: 15 Apr 2009, 16:43
by Mclaren
Thanks tribble, I got it right with the macros, my issue is with this way of doing it, the forms stay open. Is there a bit of vb that can check to see if any forms are open and then close them .

EG, on my main form i have several buttons that open each individual form. i am using access 2007 and each button is set so that a hand shows on mouse over, even if the main form is does not have focus. Now, what i want is when i click a button on the main form i need all forms to close other than the main form itself, the open the form i am selecting.

I know i can run vb code that will check each form name and close if open but if i add more forms i have to keep updating the code with new form names.

a schlep.