Moving the code out of the form is not going to solve anything here.
The fact that you move out 2, or 3 or 5 times the amount of code out of form
into a module is not going to do anything for you.
The amount of code loaded represents a VERY small portion of the forms load
time.
Assuming a disk drive can easily load 30 million charters in 1 second, if
you move out 15,000 characters of code, then you reduced the forms load time
by about (30 million - 15,000), your form now will load in 0.9995
(30 million - 15,000)
---------------------
(30 million) x 1 second = 0.9995
That means you have saved and reduced the amount of characters the form
loads by 15,000. That is in fact 15,000 times less then what the form had
before!! So, 15,000 less characters for the form loading seems like a lot,
but the above grade school math shows that this gives you a saving of about
5 - 10,000ths of a second!!! That is 5 micro seconds!!! - you can't even
measure that amount of time!!
So, clearly, the amount of code you have in the form is not going to really
change anything, and as the above shows, moving out the code is useless.
However, what will obviously change things is the amount of code that
EXECUTES!!! However, once again, code runs VERY fast, and millions of lines
of code can be run on less then 1 second. (and, I doubt you have millions of
lines of code running!!).
I assume this would speed up the form every time it was opened.
As mentioned, you are loading 15,000 less characters into the form..but the
speed up in measured in the 10,000 of a second.
So, you gain nothing really.
The real killers in form load speed is the amount of data you drag into the
form.
You don't mention much details about this form, and thus one really has to
guess as to some speed up solutions.
Are you using sub-forms? If you have a whole bunch of sub-forms behind a
tab, then you can re-write the form to NOT load the sub-forms until you
click on the tab. That means a form with 1 form, or 15 sub-forms will load
at the same speed, since you don't load all those sub-forms. Of course,
without any details as to what your form does...then it is hard to speculate
as to a solution.
So, a few tips:
Loading data into the form is what takes all of the time. You must
concentrate on this issue.
Don't load sub-forms unnecessarily. (are the sub-tables indexed
correctly?).
Same goes for combo boxes, and listboxes...use caution. Any combo that
does a lookup needs proper indexing.
Don't just load a form to a large table, but ALWAYS restrict the number
of records via the where clause
(in fact, you should restrict the form to ONE record).
I find that with small tables, say only 50,000 records, and about 4 or 5
users all working at the same time, you can get away with about 2, or 3
sub-forms, and the form load time is still below 1 second. Any more
sub-forms, then you need to put them behind tab controls..and only load when
the tab is selected.
Make sure your users get a mde, (and, of course turn off track-auto name
correct). And, ALWAYS keep a persistent connection (if you are multi-user).
It is not clear if you are talking about a multi-user setup, and the number
of records you are dealing with. And, it is not clear if you are running a
split database.
Anyway, go thought the following list:.
http://www.granite.ab.ca/access/performancefaq.htm
Then start looking at some of the tips I have above, and anything that will
cause un-necessary data to load into the form..as that is the real killer
here..