Form's Last Event

A

alex

Form's Last Event

Hello,
Using Access ’03…

I set my form’s record source in the form’s on load event; it’s
usually a SQL string.

I subsequently set the record source to “” in the form’s unload event
(this was suggested in posts I've read).

What I’ve described above has worked rather well for me in the past…
On my latest form, I have a lot of code in the form’s on current event—
code such as setting control property values.

When my new form closes, however; I’m getting an error. I understand
the error, but I don’t understand why I’m getting it!

What appears to be happening is that the form’s on current event is
firing after the form’s unload event; i.e., the form’s record source
is set to “” (in the form’s unload event) and then values are
assigned (in the form’s current event) throwing an error. I don’t
understand why the on current event is firing after the form’s unload
event. I even tried putting—me.recordsource = “”—in the form’son
close event, but the form’s current event is even firing after that!

Maybe this is by design, but I’m wondering where I could stick the
code such that it’s the last thing to fire.

I “fixed” the error I was getting by using “on error resume next” in
the form’s on current event, but I hate to do that.

Thanks,
alex
 
B

Bill Mosca

Alex

The Current event can fire for all sorts of reasons. I would just move your
recordsource code to the form's Close event. That should be safe and you
won't have to resort to a Resume Next.
 
A

alex

Alex

The Current event can fire for all sorts of reasons. I would just move your
recordsource code to the form's Close event. That should be safe and you
won't have to resort to a Resume Next.

--
Bill Mosca, Microsoft Access MVPhttp://www.thatlldoit.com














- Show quoted text -

Hi Bill; thanks for responding.

I did move the code to the form's on close event, but the on current
event is firing after the on close event!

Is the form's on close event the absolute last event that a form would
perform? According to my research it is.

I don't know what's causing the on current event to fire; I'm thinking
it might be one/some of the control's after update events since I'm
modifying the recordsource.

Thanks,
alex
 

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