Code "Disassociated" from Events

karmahum

Registered User.
Local time
Today, 09:40
Joined
Apr 29, 2002
Messages
53
Hello.

I have a form with many control and a lot of code associated with the Events of the controls. After making changes to the form the other day I noticed that most/all of the events no longer "fired" and command buttons no longer worked.

When I look at the Events list for a control (under Properties), no code is referenced. However, if I attempt to add code, it is actually there...

The only way I have been able to fix this is to copy the code from the event, delete the declaration of the event, and then recreate and paste the code into the event.

This will take a long time to fix if I have to go through each event.

I have had this problem in the past, but it usually only occurs if I change the name of an control and add a new control with that same name.

Sorry for the rambling. Any help would be greatly appreciates.

Thanks.
 
Try a Compact and Repair first.
Try going into a code module and Debug->Compile All (or project name- i cant remember which it is off the top of my head)

If this still doesn't work the following will :-

Open the form in design mode.
Open up the properties window.
For each control where the events have went missing - click on that particular event in the properties window until it says [Event Procedure]
Click the 3 dots button - close the code and repeat for other controls.

A lot quicker than cutting and pasting - but still a little slow.
 
G’day Karmahum.

Nothing wrong with the previous advice but just wondering why so many event handlers.

When there are a lot of event handlers I tend to think there is something wrong with the code.

Also, event handers can be set in code and there are not too many restrictions. One does not have to rely on hard coding the event handler and therefore breaks between the event and the handler will not happen because they can be set at Form open, even switched on the fly if you like.

For example, I have seen an application with 61 Text Boxes on a Form calling 61 event handlers and all doing the same thing. This sort of programming is not necessary and is highly undesirable. I have an application with 80 Text Boxes on a Form, and all individual events are handled by a common individual handler for that event. That means all Mouse Move events are handled by a common Mouse Move handler, same goes for Click and Double Click events, one handler for each event.

We all should know that it is not good, in a relational database, to have things defined in more than one place, that much seems certain. It violates one of the normal forms, which one I don’t care.

From days gone by we had “structured programming” which had a “data dictionary” where all things should be defined in one and one place alone.

However, the technique of having a “data dictionary” is not isolated to data alone. It relates to the method of acting on that data as well, namely the code that manipulates the data.

I therefore believe we should follow the long term trend of a “data dictionary” and have a “code dictionary” as well.

The aim of the “data dictionary” is to define, in one place, the data which we use.
The aim of the “code dictionary” is to define, in one place, the method by which we use that data.

That is why I said, “When there are a lot of handlers I tend to think there is something wrong with the code.”

Without seeing the code or the fundamental rationale behind it, it is difficult to say.

Any chance of further information?

Regards,
Chris.
 
Thanks...

Thanks for the suggestions.

Compiling, repairing and compacting did not solve the problem...

I was able to "reassociate" the code by coping all of the code out...saving the form...and then pasting it back in.

For some reason that worked!

And Chris, thanks for the suggestion. I know that there are a few fundamental problems with the form. I do not, however, have the time right now to correct them. I created the database several years ago when I was just learning...

...I would set things up very differently were I beginning on it today!

Thanks again.
 
...Pat...

If you do have time to write some code to rename the controls I would love a copy of it!

Thanks.
 

Users who are viewing this thread

Back
Top Bottom