Losing all my code and Not sure why!!!

  • Thread starter Thread starter Scuda
  • Start date Start date
S

Scuda

Morning all. I have a small DB, and for the last 2 weeks or so, people are
telling me none of the buttons on the forms are working. I went back in,
and ALL of my code has disappeared! Instead of using macros on command
buttons, I had all code.

Does anyone know why this may be happening?

Thanks in Advance,

Stephanie
 
On Thu, 8 Oct 2009 04:14:01 -0700, Scuda

One of the reasons is that you are not using best practices. You
deployed an MDB or ACCDB, not the compiled version thereof (MDE or
ACCDE). The latter don't have (plain text) code, so it cannot
disappear. Now you know one of the reasons this is a best practice.

I'm speculating you are also deploying a monolithic database, rather
than splitting your app in a front-end and back-end. If so, that's a
REALLY BAD IDEA that will certainly cause grief in the future. Since
this is a FAQ you should not have problem locating advice on splitting
your database.

-Tom.
Microsoft Access MVP
 
Thanks Tom, i concur on the MDE file, I was actually in the process of doing
just that when this problem occured. I am however doing a BE and FE.

Still stumped, thanks again.
 
Scuda,

I'm afraid I cannot shed any more light on what may have caused you VBA code
to disappear but I do know that there is no reason related to the use of code
verses macros. Infact I would believe that VBA code is more stable that any
macro.

I would suspect two things that may have happened. One is that there was
some sort of very serious corruption of your database. In this case, if you
are using the FE/BE method for deploying your applicaiton and each user had
their own copy of the front-end then the corruption most likely would not
have occurred in all copies of the front-end. From your post, I got the
feeling that even thought you have split the database, you may be still
having all users use the same front-end. If so, that is another indicator of
a possiblility of how this happened.

My other thought would be that someone may have just deleted all of the
code. I know that this is not a very realiistic possiblity but I have seen
worse.

I hope you have backups of your original code.

-----
HTH
Mr. B
http://www.askdoctoraccess.com/
Doctor Access Downloads Page:
http://www.askdoctoraccess.com/DownloadPage.htm
 
One of the reasons is that you are not using best practices. You
deployed an MDB or ACCDB, not the compiled version thereof (MDE or
ACCDE). The latter don't have (plain text) code, so it cannot
disappear. Now you know one of the reasons this is a best
practice.

Well, I think that's stronger than what it should be. I hardly ever
distribute MDEs (I have only one user of any of my current apps
using an MDE), and I've never seen code disappear in any of the MDBs
in production use.

And they aren't secured, either.
 
I would suspect two things that may have happened. One is that
there was some sort of very serious corruption of your database.

Serious code corruption doesn't happen if you use best coding
practices:

1. turn off NAME AUTOCORRECT.

2. turn off COMPILE ON DEMAND.

3. make sure that REQUIRE VARIABLE DECLARATION is turned ON.

4. make certain that all your code modules created before you did
step #2 have OPTION EXPLICIT at the top.

5. in the VBE, right click your toolbar and choose CUSTOMIZE, and
then browse to the DEBUG menu and drop the COMPILE button onto your
standard toolbar.

6. while there, also go to the VIEW menu and drag the CALL STACK
button to your standard toolbar.

7. when coding, compile regularly. That means, after every few lines
of code, hit the compile button on the toolbar.

8. periodically DECOMPILE and RECOMPILE your project (make a backup
before doing so).

If you do all of these things, you will likely almost never
encounter even minor VBA code corruption of any kind.

Of course, all of this advice presumes you are distributing your
apps properly, in the split front-end/back-end configuration, and
with each user having an individual copy of the front end.
 
Scuda,

Some early builds of Access 2007 would delete code behind forms for an
unknown reason. Check to see if you have an older build of Access 2007 and
if you do, apply the Access hotfixes that were released last fall.

This happened last year with one of my applications and the hotfix solved
the problem. Only a couple forms in my application would lose their code and
because I had a backup copy(ies) of the application, it was easy to make the
repairs. (I now regularly backup my apps.)

Another thing that I did was create an auto-repair module. When the user
discovers the problem, he/she would run the module and it would reload the
code from a backup copy of the application on the system. The hotfix however
is the best solution.

Good luck.

David
 
Back
Top