putting form Procedures into modules

pablavo

Registered User.
Local time
Yesterday, 19:32
Joined
Jun 28, 2007
Messages
189
Hello

I've heard that putting code from a forms module into a standard module can speed things up.

My question is, how would I do this? I mean, could I put lots of forms code into a standard module? and would access still know that the code was for that form?

I'm not really sure how to do this

thanks
 
I don't think it speeds things up as we would generally think of speeding our code up, that is if you have a piece of code that takes a while to run, I don't think moving it to a module is going to help. On the other hand, if you consider 'speeding things up' from a development perspective, that is how long it may take to make an enhancement to your code or maybe how long it would take to debug your code if it crashed in a production environment, I would say moving certain types of code to module would speed things up.

One pseudo rule is that you don't put code that supports business rules in the presentation layer and I'll try to explain that; In Access, forms (and reports to a lesser extent) would be considered the presentation layer. Let's say a business rule we need to have is that sales commission is going to be 10% of the base price of the item sold. In the form we could simply have an unbound text box that looks at the item price field, multiplies it by .10 and it would show us the commission. This is an example of having a business rule implemented in the presentation layer and there are several problems with this approach. First, if we have another place, say another form or a report where we need calculate the sales commission we would have to have the formula there as well. Now if the business rule changes, say the commission changed to 8%, you'd have to change it in multiple places. However, if you wrote a function that calculated the commission and placed it in say a 'business rules' module, when the rate changed, you have one place to go to and change it. There are other similar reasons to take business rules out of forms but I'll spare you the words... :)

Hope all of this makes sense.
 
the call tree?

Thans Ken

That is actually quite helpful; streamlining business reports.

The reason I asked about putting some procedures from a form module into a standard module is that, apparently, each time a form is loaded, the whole module is loaded into memory and any procedures that reference other procefures within different modules would be loaded into memory along with their modules and so on.

The books i've read say this has been addressed with access 2003 and as long as compile on demand is ticked this shouldn't be too much of a problem.

However, apparently it's still quicker to put some code into standard modules.

Anyway, you wouldn'd know how to do that?

Thanks




hat are inside that one module and if any of these procedures reference code within other modules, those too, are called.
If some of the forms code (that doesn't have to be called when the form loads) is put into a standard module, then (apprehently) it wont be called, therefore, there woule be less code to
 
I think you're over-complicating the issue. A 'standard' module is simply a place where you put code that is not associated with an object (in this case forms). To create a standard module you simply do database window->modules->new. Then create a new procedure (or function) and put your code there. Then call it from a form/form object event.

Again, don't think that you'll be putting all of the code you would normally put in a form module into standard modules, just strategic bit's and pieces...
 

Users who are viewing this thread

Back
Top Bottom