Codes behind form all gone!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

OK this has happened to me a few times now so I don't think it can be purely
user error or accident. Has anyone ever encounter the situation where you
were working along in your codes and a few minutes later you went back in
behind the form to look at something and found that all your codes for that
form were GONE? This happened again to me this afternoon and I'm sure you all
can relate the horror of looking at a blank screen. Luckily or unluckily, I
have a backup from a couple of days ago.

Can I accidently deleted the codes myself? Unless I have Selected All and
hit delete or something, can I still make such a mistake? If anyone know why
I would greatly appreciate the pointers because I sure the heck don't want
this to happened again.

thanks.
 
There are two ways to purposefully delete all the code from a form - Select
All, Delete, or set the form's HasModule property to "No".

A more likely explanation is database corruption. Try the following steps:

1. Take a backup copy of your old MDB file

2. For the form which is misbehaving, copy all the code and paste it into a
temporary text file, then set its HasModule property to "No" and save the
form.

3. Create a brand new database and import all the objects from the old one.

4. Open the form's module (which should be blank) and paste the code you
have saved in the text file.

5. Add any references as required and recompile the VBA project.
 
I can see from your suggestion that setting the HasModule property to No will
delete the codes behind the form. Access at least popped up a warning. This
afternoon I was test inputting some data but the system was 'hanging' or not
responding at times so I closed out of Access. When I came back in, I was
going to continue going through the codes only to discover that there were no
codes as all. All the controls and Event Procedure calls were still in the
form properties but just no codes. Only the Option compare and Option
Explicit. I certainly wasn't highlighting anything and certainly not Select
All. How else can one get rid of all the codes in a particular form? Has
Access been reported to have done anything like this?

Graham Mandeno said:
There are two ways to purposefully delete all the code from a form - Select
All, Delete, or set the form's HasModule property to "No".

A more likely explanation is database corruption. Try the following steps:

1. Take a backup copy of your old MDB file

2. For the form which is misbehaving, copy all the code and paste it into a
temporary text file, then set its HasModule property to "No" and save the
form.

3. Create a brand new database and import all the objects from the old one.

4. Open the form's module (which should be blank) and paste the code you
have saved in the text file.

5. Add any references as required and recompile the VBA project.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

kdw said:
OK this has happened to me a few times now so I don't think it can be
purely
user error or accident. Has anyone ever encounter the situation where you
were working along in your codes and a few minutes later you went back in
behind the form to look at something and found that all your codes for
that
form were GONE? This happened again to me this afternoon and I'm sure you
all
can relate the horror of looking at a blank screen. Luckily or unluckily,
I
have a backup from a couple of days ago.

Can I accidently deleted the codes myself? Unless I have Selected All and
hit delete or something, can I still make such a mistake? If anyone know
why
I would greatly appreciate the pointers because I sure the heck don't want
this to happened again.

thanks.
 
Well, as I said, "a more likely explanation is database corruption."

Have you tried the steps I suggested to rectify this?

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

kdw said:
I can see from your suggestion that setting the HasModule property to No
will
delete the codes behind the form. Access at least popped up a warning.
This
afternoon I was test inputting some data but the system was 'hanging' or
not
responding at times so I closed out of Access. When I came back in, I was
going to continue going through the codes only to discover that there were
no
codes as all. All the controls and Event Procedure calls were still in
the
form properties but just no codes. Only the Option compare and Option
Explicit. I certainly wasn't highlighting anything and certainly not
Select
All. How else can one get rid of all the codes in a particular form? Has
Access been reported to have done anything like this?

Graham Mandeno said:
There are two ways to purposefully delete all the code from a form -
Select
All, Delete, or set the form's HasModule property to "No".

A more likely explanation is database corruption. Try the following
steps:

1. Take a backup copy of your old MDB file

2. For the form which is misbehaving, copy all the code and paste it into
a
temporary text file, then set its HasModule property to "No" and save the
form.

3. Create a brand new database and import all the objects from the old
one.

4. Open the form's module (which should be blank) and paste the code you
have saved in the text file.

5. Add any references as required and recompile the VBA project.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

kdw said:
OK this has happened to me a few times now so I don't think it can be
purely
user error or accident. Has anyone ever encounter the situation where
you
were working along in your codes and a few minutes later you went back
in
behind the form to look at something and found that all your codes for
that
form were GONE? This happened again to me this afternoon and I'm sure
you
all
can relate the horror of looking at a blank screen. Luckily or
unluckily,
I
have a backup from a couple of days ago.

Can I accidently deleted the codes myself? Unless I have Selected All
and
hit delete or something, can I still make such a mistake? If anyone
know
why
I would greatly appreciate the pointers because I sure the heck don't
want
this to happened again.

thanks.
 
Back
Top