External Module select control on active form (1 Viewer)

Cowboy_BeBa

Registered User.
Local time
Today, 22:42
Joined
Nov 30, 2010
Messages
188
So ive written a bit of code that needs to be applied to each form on form load

its very basic, just changes an image source on each form (to one stored in a table) and the forms header colour

two lines of code
me.formheader.backcolor=dlookup,,,
me.recLogo.picture=dlookup...

now as these two lines of code are exactly the same and need to be applied to every form on the DB i thought it would be best to store them in a public function on a separate module, this way if ever i need to edit the code i just change it in one place instead of on every page (not to mention its a bit cleaner to have it in one spot than to have it copy/pasted on every form_load event)

the problem is the keyword "Me" has no meaning when used outside of a form or report
so my question is how do i replace "Me" with the currently active form?

ive done something similar in the past (albeit with one specific form), in which the code was something like
Forms!formName.ControlName.Property = whatever
But that doesnt apply here because the form name is subject to change

does anyone know what i can do to remedy this? thought of creating a variable as an object and then making the variable equal whatever the active form is, but not sure how to actually do that last part

is what im attempting even possible?
 

JHB

Have been here a while
Local time
Today, 16:42
Joined
Jun 17, 2012
Messages
7,732
Create a sub in a module:
Code:
Sub ChangeFormProperty(FormObject As Form)
  FormObject.FormHeader.BackColor = dlookup,,,
End Sub
And call it from a form:
Code:
  Call ChangeFormProperty(Me.Form)
 

Cowboy_BeBa

Registered User.
Local time
Today, 22:42
Joined
Nov 30, 2010
Messages
188
you sir (or madam) are a complete legend and a saint
your solution worked perfectly :)
thank you very much for the help
 

JHB

Have been here a while
Local time
Today, 16:42
Joined
Jun 17, 2012
Messages
7,732
You're welcome - and I think probably my wife prefers that I am a man. :D :D
 

Cowboy_BeBa

Registered User.
Local time
Today, 22:42
Joined
Nov 30, 2010
Messages
188
lol, good to know (tbh i figured as much, but didnt wanna make any assumptions..... although i guess i did make an assumption.... damn being politically correct can be a pain in the backside)
 

Users who are viewing this thread

Top Bottom