OnUnload calling OnCurrent??

P

Pelton98

I am using the information from the following site to speed up performace on
my FE DB.
http://www.granite.ab.ca/access/performanceforms.htm

I notice a vast improvement, but I can't set the Me.form.recordsource = ""
on the Unload Event

It appears that when my form is unloading it is looking into the Form
OnCurrent Event.

I have code in my oncurrent event that populates to unbound text boxes with
values from a combobox.

Two Questions...Is it that important to set my recordsource for the form to
"" and second why is the unload event firing then the oncurrent event.

I even noticed that the On CLose event also fires before the Oncurrent
event.

Makes little sense to me, but then again I am not a guru like some of you.
 
B

Brainlord Mesomorph

Hmm, I read the article and I *THINK* I may understand some of why
that works.

(caveat: I really don't *know* how MSA works behind the screen, but I
know some of how Windows (and MS) does things. so here goes)

When MSA loads a forms it does something like most of these things in
somthing like this order:

1 read the form description / build a blank form in memory
2 read and cache data for picklists and comboboxes etc.
3 read and cache (at least some of) the Datasource of the form so it
can populate records.
4 put the form on the sceen,
5 put the cursor in the first field

Now VB subs (triggered by these Events) run concurrently, and in a
seperate VB Executive "thread," as opposed to the MSA thread(s)
(because windows multitasks, but very well)

So, in the Mark Plumpton post, we have a form with NO data sources.
so the cpu skips steps 2 and 3, and just pops the form on the screen,
seperately the VB Executive is reseting the datasources and caching
all that data.

So we seem to have a dramatic improvment of preformance.

I wonder if the user can actually get into the fields and enter or
retrieve data any faster (or are there other, perhaps unnoticable
delays later as they use the form)

No about OnCurrent:

Whenever you change the Recordsource of a form, MSA is forced to move
from one record, to a new (perhaps blank) record in the new
datasource. (even if its an empty string) That triggers your OnCurrent
event.

But in the Mark Plumpton post, changing the recordsource on form close
is only a precaution. Just make sure you naver *save* a RecordSource
for the form and you can forget that Form_Unload code

hth
BLM
 
N

Nikos Yannacopoulos

Alternatively to Brainlord's suggestion, you could try adding the
follwing as the first line your OnCurrent event sub:

If Me.RecordSource = "" Then Exit Sub

HTH,
Nikos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top