Code in Detail_Format of report causes Access 2002 to crash

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

Guest

I have a simple 'if' statement in the Detail_Format subroutine of an Access
2002 report:

If Me.EXPIRED_DT < Date Then
With Me.Check14
.Value = True
.Visible = True
End With
Else
With Me.Check14
.Value = False
.Visible = False
End With
End If

It worked fine until yesterday, when I attempted to add:

Me.EXPIRED_DT.Forecolor = vbred

when the EXPIRED_DT is < Date, and:

Me.EXPIRED_DT.Forecolor = vbblack

when it's not.

I added these lines, ran the report, and Access crashed. I removed the
lines, and Access still crashes when I run this report. What's worse, this
report is actually a subreport to several other reports, so now none of them
work.

When Access dies, it backs up the db, compacts and repairs it, then reopens
the new version, but the error continues to occur. The error report claims
the problem is with an offset in mso.dll, which, of course, is of no help to
me.

Any ideas>
 
Access has corrupted your code. There are several things that could have
caused this, so try this sequence.

1. Uncheck the boxes under Name AutoCorrect in:
Tools | Options | General
Explanation:
http://members.iinet.net.au/~allenbrowne/bug-03.html

2. Compact the database:
Tools | Database Utilities | Compact

3. Decompile a copy of the database by entering something like this at the
command prompt while Access is not running. It is all one line, and include
the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

4. If you are able to open this report in design view and see the code in
its module, copy the code (ctrl+A, Ctrl+C), and paste it into Notepad. Then
set the report's HasModule property to No so that it loses the code. Save
the report.

5. Compact again.

6. Open the report in design view, and view its (now empty) module. Paste
the code back in again from Notepad.

7. Still in the code window, choose References from the Tools menu. Make
sure that none are marked "MISSING". Deselect any references you are not
actually using: you may be able to get it down to just three. More info on
references:
http://members.iinet.net.au/~allenbrowne/ser-38.html

8. Check that the code compiles:
Debug | Compile

That should get you going. Post back if you are still stuck. There is a bug
with subforms in Access 2002 and 2003 where it crashes if the field named in
LinkChildFields is an AccessField, i.e. there is no text box for this field
in the subform. Adding a text box (Visible = No if you like) works around
the problem. I haven't experienced this with reports, but it may be there.

General guidelines on preventing corruption:
http://members.iinet.net.au/~allenbrowne/ser-25.html
 
My goodness! I've never seen such a thorough and relevant response in a
newsgroup post before! I will try each of these possible remedies when I get
back to work on Monday. I'm sure the answer's in there somewhere.

I do recall some strange goings-on when I was trying to close the report
earlier in the day of the crash. It kept asking me upon closing the report
if I wanted to "save the module" when I had made no changes in any "module"
other than the Detail_Format procedure. I kept saying no, but it wouldn't
let me close the report, so I had to click Yes just to close the thing.
Everything went down hill from there. I will surely post the fix. Stay
tuned...
 
Ok, here's the deal...

1. I had already turned off AutoCorrect

2. I compacted and repaired again

3. Decompile did not work. Same crash occured when I attempted it.

4. Code was already copied out of the module (into this post)

5. Could not get back into the database after faile decompile. Access
complained about there having been some "extreme" error that had closed the
database previously, and would not open the db again, hence I was unable to
try steps 5, 6, and 7.

What I did do was create a blank database and import all the tables, forms,
queries, reports, and modules. When importing the reports, it stopped at one
of them and said there was a duplicate module name. The resultant database
continually locked up on me.

I did the whole process again, this time omitting the offending report, and
life's a charm again. I will have to recreate that report, but my data is
secure, my queries, forms, and reports (other than the broken one) all work
fine.

Given my newly functional database, I wanted to try this Debug, Compile
option just to ensure all was well. I opened a report, opened the code
window, and clicked Debug. "Compile," however, is not highlighted. How is
this supposed to work?

-Steve-
 
Hi Steve. Brilliant. You've traced that well, and got everything except the
corrupted report. You may even be able to import that report from an old
backup copy of the database through File | Get External | Import.

The Compile option on the Debug menu will be greyed out if the project is
already compiled and everything is fine. If you open any code window and
make a change, the menu item should become available again.

The fact that the Decompile failed indicates that the corruption was worse
than merely the two versions of the code (text and compiled) being out of
sync. The message about modules with duplicate names confirms this, and
hints that the corruption was probably caused by Name AutoCorrect, and/or by
editing the code in break mode (i.e. not in design view).

It's very satisfying when you recover your database like that.
 
Back
Top