VB for form corrupt? (1 Viewer)

davea300

Registered User.
Local time
Today, 23:38
Joined
Mar 16, 2007
Messages
164
Hi

I have a small database with one form containing 4 small subforms. Whenever I click any of the buttons on the form I get this error:

"The expression OnClick you entered as the event property setting produced the following error: object or class does not support the set of events"

I've seen this before many times, went into the event procedure of the OnClick event and fixed it. Problem this time is I can't get into the event procedure. When I try and get into the code for any button access crashes and throws me out. I can't even get in to copy it.

I've tried compact and repair and creating a new db file/importing everything again.No joy. Tables,queries, reports all work fine.

Looks like corrupt code on the form but i'd rather not spend time rewriting it as some was quite tricky to get working in the first place, any suggestions?

p.s. I had 2 backup copies of this database (one saved locally) and both of them are doing the same thing which is really puzzling me! Tried it on another PC as well!
 
Last edited:

davea300

Registered User.
Local time
Today, 23:38
Joined
Mar 16, 2007
Messages
164
Just realised, the same thing is happening with other databases I have. Try and open the VB code and access crashes, shows me a Send/Don't send error message and reopens.

I just created a new database file with one form and one button which exits the application. It throws up the same error.
 
Last edited:

Vonnie

Registered User.
Local time
Today, 15:38
Joined
Aug 21, 2008
Messages
57
Might have to reinstall Access. No way any libraries were deleted or corrupted by other installs?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 23:38
Joined
Sep 12, 2006
Messages
15,660
might be your references have changed

open a code module, do tools references

most likely DAO has been supplanted by ADO

this seems to make loads of things stop working

eg - see if entering left( in the code module says function not recognised - it all seems to be related to bad references
 

CyberLynx

Stuck On My Opinions
Local time
Today, 15:38
Joined
Jan 31, 2008
Messages
585
Most likely your Form is Corrupt. There is no repair for this that I know of other than deleting the Form then copy and paste in another from a backup .mdb.

First check the References within the VBA Editor. Make sure none are indicated as MISSING. If there is then reestablish them and then try your Form again. If not, you will most likely need to redo he Form.

You may be able to save the underlying code within the Form but chances are it will crash yet again when you try to access the code module through the VBA Editor. You may even be able to repair the code if you can access the Form's code module. To do this though, you will need to access a different Form's code module first then from the Project Window within the VBA Editor, double-click on the Form Code Module for the corrupted Form.

If it Opens into the Editor then you are in luck. Ensure that the Option Explicit statement is placed at the top of the code module within the Declarations Section. Then from the VBA Editor menu select Debug | Compile. If there are errors in code then this should point them out to you. Make the necessary corrections and then Compile again. Keep doing this until there are no errors. Now do a Database Compact & Repair.

If the Form still doesn't work then it is corrupted beyond repair. Access the Form Code Module again as explained earlier then select (highlight) all the code within it. Copy the Code into NotePAD (or whatever text editor you prefer) and save it. Close the VBA Editor then Delete the Form from within the Database Object Window. Copy and Paste the Form from your DB backup copy (if you have one) into the faulty DB. Close the Backup DB then from the Faulty DB, open that Form's Code Module.

From the VBA Editors Edit menu select the Select All menu item. All the code now in the Form's Code Module will be highlighted. Now select all the code you placed into NotePAD and copy it then paste it into the Form Code Module now open in the VBA Editor.

If you are successful with this then you have managed to at least salvage the Form's underlying Code.

Good luck.

Make Backups Of Your Database On A Regular Bases....Especially During Development.

.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:38
Joined
Feb 19, 2002
Messages
43,352
When things get this flaky, do a hard reboot.
 

Users who are viewing this thread

Top Bottom