Subform Referencing Parent Form Functions

warmexxus

New member
Local time
Yesterday, 22:17
Joined
Mar 10, 2009
Messages
7
Good morning,

I'm using one main form that contains any number of subforms. Each subform will have more subforms within it. So it's a three layer cake. Parent, Sub, Subsub.

My question is about functions that run on the subsub forms. Should the functions be local to the subsub forms? Should all functions that run on subsub forms be located in subsub form code?

The reason I'm saying this and I'm confused trying to explain, is because currently I'm writting all functions on the parent forms. Then I call the functions by reference from the subsub forms. (me.parent.functionname).

The reason for this is I wanted to have as much code on one form as possible. This helps me to see everything that is happening in one place. Is this a less efficient way to code form functions? Will the subs have performance issues with having too much code?

For example. A Keyup Event on the subsub form won't filter the subsub form locally, instead it will call my filter function from the parent form.

There is no emergency here its just a code ethics question. :)

Thank you for the input.
Dan
 
Thank you for that helpful link. I examined your database and everything was explained very clearly. At this point I am already referencing everything I need and it all works just fine. My question was more of an opinion of a specific situation I was wondering about. I'm not exactly having any problems, out of the norm, as of yet.

Again, just curious is it proper to keep all code that affects a form in it's own code block? Could it affect the performance of a form negatively to have too much code? Lastly, is common for the parent form to control the subform completely from the parent form? I'm not talking about events occuring, but the code written by myself for when an event occurs.

Thank you again.
Dan
 
Again, just curious is it proper to keep all code that affects a form in it's own code block? Could it affect the performance of a form negatively to have too much code? Lastly, is common for the parent form to control the subform completely from the parent form? I'm not talking about events occuring, but the code written by myself for when an event occurs.
what do you mean by it's own code block? each form is an object, in it's own class. form code is seperated by specific procedures (event procedures, private functions, etc...). and yes, too much code behind a form really bogs it down, but only if it's utilized. You can write a million lines of code behind a form, but if you don't run any of it and use it, it's just text memory or space ( I think).

and i don't really get your talk about the "controlling" of the different forms. it's just a sense that you have to develop. I think you'll do fine with what you got. more questions , just post. =)
 
Again, just curious is it proper to keep all code that affects a form in it's own code block? Could it affect the performance of a form negatively to have too much code? Lastly, is common for the parent form to control the subform completely from the parent form? I'm not talking about events occuring, but the code written by myself for when an event occurs.

Thank you again.
Dan
As far as I know a large amount of code will mean the form is slow to load as the the form module is loaded when you open the form.
 
Lastly, is common for the parent form to control the subform completely from the parent form? I'm not talking about events occuring, but the code written by myself for when an event occurs.
I keep the code for each form in the form it is for (parent code on parent, child code on child). If I need it in more than one place then I will put it into a public function in a standard module.
 

Users who are viewing this thread

Back
Top Bottom