Access 97 - Event handlers 'disappear'

  • Thread starter Thread starter Marc Hillman
  • Start date Start date
M

Marc Hillman

I have this really bizarre problem when I do major changes on a form. An
explanation and solution would be much appreciated.

I sometimes do a lot of rearranging of controls using cut/paste. The control
names do not change. After doing this surgery the Event handler code isn't
called. So all I do is cut out the code body of the handler, delete the
handler, and then recreate it. All is EXACTLY as before, in the some place
in the code, yet it now works. I've done "Repair", "Compress" and even
"/decompile", but the problem persists. I have to manually go through all
the handlers and cut/paste them to make them work.

Any ideas what's causing this?

Delete "REMOVE" from my reply address
_______________________________________
Marc Hillman, Melbourne, Australia
web: http://users.tpg.com.au/mhillman/
 
In Event properties for the control, make sure that that [Event Procedure]
shows up on the event you wish to tigger, eg On Click. Otherwise the code
may be in your module but has nothing to tell it when to run.

Mich
 
Marc Hillman said:
I have this really bizarre problem when I do major changes on a form.
An explanation and solution would be much appreciated.

I sometimes do a lot of rearranging of controls using cut/paste. The
control names do not change. After doing this surgery the Event
handler code isn't called. So all I do is cut out the code body of
the handler, delete the handler, and then recreate it. All is EXACTLY
as before, in the some place in the code, yet it now works. I've done
"Repair", "Compress" and even "/decompile", but the problem persists.
I have to manually go through all the handlers and cut/paste them to
make them work.

Cutting and pasting the control clears the "[Event Handler]" entries in
the control's various event properties (on the Event tab of the
control's property sheet). As far as Access knows, you're pasting this
as a new control, so it doesn't know that you want to maintain a link to
an existing event procedure. You don't have to cut and paste the event
procedures again to fix this, but you do have to re-enter "[Event
Procedure]" (or double-click) on the appropriate event property lines of
the property sheet.

If you do this a lot, I expect you could write a public function or
procedure to do this fixup -- scanning the form's module for event
procedures, parsing out the related control and event names, and then
resetting the controls' event properties. I've never taken the trouble
to do it, however.
 
Not "bizarre", as the others have explained :-)

If the names of the controls are unchanged, here's the easiest fix for your
problem. Do all the cutting & pasting of controls that you want. Then go to
the form module, select all lines in the module, cut them out, then paste
them back. Re-save the module. Voila!

HTH,
TC
 
Back
Top