Hi All
On a number of my forms there are header and footer sections which are set to a specific colour but I wanted to make it a little more user configurable by allowing a user to select a colour theme/scheme that will apply to all headers and footers.
I already do a couple of things as a form loads and they are done in a module so i thought i could add me.formfooter.backcolor and me.formheader.backcolor VBA to that.
But i realised that wouldn't work so i changed that to:
Forms(formName).FormHeader.BackColor
Forms(formName).FormFooter.BackColor
Where formName is passed to the module VBA public sub
But this kept throwing up an error: "cannot find the referenced form"
I then thought it might be because of the form event order that might mean that on load the form isn't accessible so i tested that out by using the Current event but still get the same issue.
Its frivolous and not necessary which is all the more infuriating that i'm not able to do it as i'm sure its just a matter of understanding event orders and stuff like that.
If i put the code directly into either the load or current events like this:
then the header and footer back colours change, its just if i move it to a generic sub in a module that it can't find the form using the forms name so i just would like to understand why in case in the future i need to do something less pointless and need to do this
hope that makes sense. here is the code that i have in the module:
And on the form event i do this:
i've also tried
And both do the same thing so pretty sure its just a my understanding issue
Kind regards
Glen
On a number of my forms there are header and footer sections which are set to a specific colour but I wanted to make it a little more user configurable by allowing a user to select a colour theme/scheme that will apply to all headers and footers.
I already do a couple of things as a form loads and they are done in a module so i thought i could add me.formfooter.backcolor and me.formheader.backcolor VBA to that.
But i realised that wouldn't work so i changed that to:
Forms(formName).FormHeader.BackColor
Forms(formName).FormFooter.BackColor
Where formName is passed to the module VBA public sub
But this kept throwing up an error: "cannot find the referenced form"
I then thought it might be because of the form event order that might mean that on load the form isn't accessible so i tested that out by using the Current event but still get the same issue.
Its frivolous and not necessary which is all the more infuriating that i'm not able to do it as i'm sure its just a matter of understanding event orders and stuff like that.
If i put the code directly into either the load or current events like this:
Code:
Me.FormHeader.BackColor = 12040191
Me.FormFooter.BackColor = 12040191
hope that makes sense. here is the code that i have in the module:
Code:
Public Sub setHeaderAndFooterColours(formName As String)
Forms(formName).FormHeader.BackColor = 12040191
Forms(formName).FormFooter.BackColor = 12040191
End Sub
And on the form event i do this:
Code:
Private Sub Form_Current()
Call setHeaderAndFooterColours(Me.Name)
End Sub
i've also tried
Code:
Private Sub Form_Load()
Call setHeaderAndFooterColours(Me.Name)
End Sub
And both do the same thing so pretty sure its just a my understanding issue
Kind regards
Glen