Hide/Unhide Form Header (subform/form)

SueBK

Registered User.
Local time
Today, 23:11
Joined
Apr 2, 2009
Messages
197
I have a form with a subform (let's call them Form01 and SubForm01). SubForm01 is also used as a stand-alone form, accessed from a command button on another form (Form02). All my forms (dozens of them) have a standard header - client logo, title, exit button, background colour etc.

When SubForm01 opens as part of Form01 I want the header hidden. When it is opened as a standalone form from Form02 I would like the header visible. I know how to do one of the other simply by setting the visible setting in the properties.

Is it possible to code the command button to open the form with the header visible? And still keep it hidden when it's used as a subform?
 
i wouldn't even mess with the subform itself. use the ONLOAD() event of the main form and hide the header of the subform container upon opening it. since that is the only time you need to hide it, forget about the stand alone instance. it should not be relevant. then, with the UNLOAD, or CLOSE() events, bring it back to visible so it is there the next time it is opened via stand alone.
 
Having some difficulty getting the header to hide when I open the main form. The code I'm using is:

Code:
Private Sub Form_Load()
Me.tblRoles_Subform.SetFocus
Me.FormHeader.Visible = False
End Sub

I'm a little confused because the sub-form is actually called "subfRolesSubform". I don't understand where the "tblRoles_Subform" - but that's what comes up when I click the sub-form in design view; AND the 'real' title of the subform is not on the drop down list after "me.".

At the moment, this code is turning the header of the main form off; so I'm guessing my "set focus" line is the real issue here.
 
As far as I can see Me.FormHeader is not a valid argument.

Code:
Me.FormHeader.Visible = True
... works. It turns off the form header BUT on the main form not the sub form :(

I can't work out how to get the code to set the focus to the sub-form and THEN run the command.
 
Code:
Me.FormHeader.Visible = True
... works. It turns off the form header BUT on the main form not the sub form :(

I can't work out how to get the code to set the focus to the sub-form and THEN run the command.

Does it? Have you tried running that command in an On Click event of a button?
 
Does it? Have you tried running that command in an On Click event of a button?

Not sure why I would, but I tried it and it still works. Put the same line against a command button and when I click it - it turns off the header (of the main form).
 
What version of Access are you using? As it returns an error in Access '03
 
I'm using 03. I've tried it in two different databases; and it works perfectly - hides the (wrong) header every time.
 
Never mind I've figured out why it wasn't working for me. You must first have the header/footer visible in design view :o

Try;
Code:
Private Sub Form_Load()
     Me!tblRoles_Subform.Form.SetFocus
     Me!tblRoles_Subform.Form.FormHeader.Visible = False
End Sub

For future reference bookmark this page as it has the correct references for Subforms and their properties.
 
Last edited:
Thanks for the link. I've sent it to our Access team (most of us being rank beginners).

But the code isn't working.

As I write it, it doesn't give me "formheader" as an option in the 2nd line. When I run it, it says it doesn't like the first line. (Run time error 2449; There is an invalid method in an expression."

The code I'm using is:
Code:
Private Sub Form_Load()
Me.RolesSubform.Form.SetFocus
Me.RolesSubform.Form.FormHeader.Visible = False
End Sub

(I've changed the sub-form name to something more logical than it was.) I'm using the event "load" on the main form.
 
You will need to make sure that the form/subform actually has a header and or footer visible in design view. This is the problem I ran into when I first started looking at your code. ie. you can not use this code to show or hide a header/footer if the form does not have one in the first instance.
 
I tried this in the load event of the main form, and it hid the form header of the subform:

Me.SubFormControlName.Form.FormHeader.Visible = False

It is the name of the control that's needed here, if it's different than the subform.
 
Sorry John, you showed as offline when I started posting.
 
I tried this in the load event of the main form, and it hid the form header of the subform:

Me.SubFormControlName.Form.FormHeader.Visible = False

It is the name of the control that's needed here, if it's different than the subform.

This appears to work for me. YAY! I knew it would end up being a simple answer. Thank you for input. I learn more each day.
 

Users who are viewing this thread

Back
Top Bottom