MS Jet cannot find form that's there

D

Doug Chapman

I just created a form and have been using it for several hours. It has a VBA
module. Now suddenly I can't open it, even in Design view (I get the message
'MS Jet database engine could not find the object Form1'), and when I try to
open its module in VBA I get the message 'you canceled the previous
operation'. Apparently it's been corrupted. I spent hours designing it and
would like to retrieve it! (I already tried exporting it to another DB, also
went to another DB to import it, with the same result when I try to open it
in the other DB.)

(For what it's worth, the problem first appeared after I tried to open a
table in design view and got the message I couldn't do that because a 'form
or query' it was linked to was open -- which was not correct. I closed and
compacted the DB and reopened, and started having the problem with the form,
though not with the table.)
 
A

Allen Browne

Doug, I'd be interested to know which part of Access thinks the form is not
there: MSysObjects, the AllForms collection, or the VBA project part.

Open the Immediate Window (Ctrl+G), and try:
? DLookup("[Type]", "MSysObjects", "[Name]='Form1'")
You will get -32768 if it finds it.

Then try:
? CurrentProject.AllForms("Form1").IsLoaded
You will get False if it finds it and believes the form is not open.

If one of those two finds it and the other does not, you have a fairly rare
kind of corruption, where the two canonical lists of forms in Access (2000
or later) don't match. Rebuilding the form is probably the only solution.

If both find the form, you could try the undocumented
SaveAsText/LoadFromText:
http://allenbrowne.com/ser-47.html#SaveAsText

If neither find it, it's gone.

If the problem is only with the form's module, there are a couple of
approaches. If you can see the code in the form's module (in one of the
windows of the VBA code IDE), copy it out to notepad and save it. Then see
if you can set the form's HasModule to No (answering Yes to the confirmation
to destroy the VBA code.) Compact. Repair. Decompile. Compact. Repair. If
the form is usable, you can then paste the code back in.
 

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

Top