Forms keep crashing

J

John Dumay

Hi,

Sometime when i edit a form's VBA code, then compile and saving the form my
database becomes corrupted as when i try to open the form i get the following
message - "The expression On Open you entered as the event property or
setting produced the following error: Object or class does not support the
set of events."

i have been good at backing up my db after every major code change, and
usually i can go back and make the changes and have them work. But why does
this keep happening? It seem illogical to me. And if it does happen how can i
fix it withour redoing my work?

Thanks,

John
 
D

Dirk Goldgar

John Dumay said:
Hi,

Sometime when i edit a form's VBA code, then compile and saving the form
my
database becomes corrupted as when i try to open the form i get the
following
message - "The expression On Open you entered as the event property or
setting produced the following error: Object or class does not support the
set of events."

i have been good at backing up my db after every major code change, and
usually i can go back and make the changes and have them work. But why
does
this keep happening? It seem illogical to me. And if it does happen how
can i
fix it withour redoing my work?


Despite your experience, this is not all that common, so there must be
something about your work environment or practices. I can only think of a
couple of things off the top of my head:

1. Do you often modify a form's code while the form is open in Form view (or
Datasheet view, or any view other than Design view)? That has been known to
result in corruption. Although I have, upon occasion, modified code while
the form was open and running, I considered myself lucky. Make sure you
have your forms and reports open in Design view before editing the code.

2. Are you working on the database across the network? Don't. Always work
on a copy of the database that is stored on your own computer. If you're
working remotely via terminal services or Citrix, though, that's okay.
 
J

John Dumay

Hi Dirk,

I am pretty religious about closing the form and then working on it from the
VBA editor, compile, save, close VBA and then reopen the form to test it.

I always work on a copy of my DB. So before i make changes i back it up
first and then procede. If is crashed, i copy the backed up copy and use it
while alwys retaining an orignal non-cracshed version.

Also i work on a laptop with Vista Business operating system.

Regards,

John
 
D

Dirk Goldgar

John Dumay said:
Hi Dirk,

I am pretty religious about closing the form and then working on it from
the
VBA editor, compile, save, close VBA and then reopen the form to test it.

That sounds fine.
I always work on a copy of my DB. So before i make changes i back it up
first and then procede. If is crashed, i copy the backed up copy and use
it
while alwys retaining an orignal non-cracshed version.

That's another good, cautious procedure. I can't find fault with it.
Also i work on a laptop with Vista Business operating system.

And that shouldn't make any difference.

Does you have this problem with one specific database, or have you
experienced it while working on a variety of different databases? I'm
wondering if you may have some hidden corruption in the database you are
working on, that keeps surfacing. If so, you might cure it by decompiling
the database, compacting, then compiling, then compacting again. Have you
tried decompiling the database? This procedure isn't much documented (and
should only be performed on a copy of the database, not on your only good
version).
 
D

david

What version of Access? And are the forms complex?

Sometimes you can fix this with a decompile, or by
importing everything into a new database. Sometimes not.

(david)
 
D

Dirk Goldgar

John Dumay said:
Dirk,

No I haven't decompiled and recompiled. How can i do this?


* * * Steps to Decompile an Access Database * * *

1. With the database closed -- no users in it at all -- and (ideally) Access
not running, make a backup copy.

2. On the task bar, click Start -> Run... (or the equivalent for your
version of Windows).

3. Enter this (adapted to match your database path and name) in the Run
dialog box and click OK:

msaccess.exe /decompile "C:\My Documents\YourDBName.mdb"

You may need to include the full path to msaccess.exe, but I don't find that
to be the case when I try it. Depending on your Access version, you may not
get any sign that anything in particular happened. Your database will
probably open in Access.

4. Compact and Repair your database.

5. Open the database again, press Alt+F11 to switch to the VB Editor, and
click Debug -> Compile (your project). If any errors appear, fix them and
recompile.

6. Close the VB Editor. Compact & Repair again.

That will usually clear out any code corruption.
 
J

John Dumay

Hi Dick,

That didn't work. Actually what happened when I decomiled is that it totally
corrupted the database. So it took a version that was working before and now
the same error comes up.

Regards,

John Dumay
 
J

John Dumay

i David,

Yes the form in question is very complex.

I am using Access 2003 on a Windows Vista Business edition OS.

See my response to Dirk re the decompile and recompiling.

Regards,

John
 
D

Dirk Goldgar

John Dumay said:
Hi Dick,

That didn't work. Actually what happened when I decomiled is that it
totally
corrupted the database.

Good thing you had a backup, then.
So it took a version that was working before and now
the same error comes up.

You mean, in the version that you decompiled? Because there's no way a
decompile of one copy can corrupt some other copy.

Try creating a new blank database, and then importing all the objects from
the problem database (preferably a version that is currently working) into
it.
 
D

david

See my response to Dirk re the decompile and recompiling.

Yes, there is no point worrying about if the problem is
irresolvable until you can do a clean decompile without
crashing. Do you have an class modules? Some class
modules always cause problems with decompile, if it's not
that you should be able to get a clean decompile.

(david)
 

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

Similar Threads


Top