The form is there but database can't find it!!!

G

Guest

After editing and saving the main form in an Access 2000 application I tried
to open it again, but clicking on the form's name did nothing. No errors,
just nothing. Grrrrrr.

Running Compact & Repair didn't fix it, so I opened a new database and
imported all the objects from my corrupted database. Clicking on my main form
now gave the error "The Microsoft Jet database engine could not find the
object 'Formname'. Make sure the object exists and that you spell its name
and the path correctly".

Luckily I have a fairly recent backup, but is there any way of recovering
the corrupted form?
 
A

Arvin Meyer [MVP]

In the Immediate window of your corrupt database, try using:

? Application.SaveAsText acForm, "FormName", "C:\Document\FormName.txt"

If you get a text file, you are probably fine. The in the new database, try:

? Application.LoadFromText acForm, "FormName", "C:\Document\FormName.txt"
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
A

Allen Browne

Access sometimes gets confused about the name of the object.

Create a new query (no table).
Switch it to SQL View.
Paste in this statement:
SELECT MSysObjects.Name FROM MSysObjects
WHERE MSysObjects.Type = -32768
ORDER BY MSysObjects.Name;

See if the form is there by another name.
If it is, you *may* be able to export it with this undocumented statement:
SaveAsText acForm, "Form1", "C:\Form1.txt"
where Form1 represents the name of the form.
If that works, you can then import it into the new database with
LoadFromText.

To prevent this kind of corruption, make sure that the Name AutoCorrect
boxes are unchecked under:
Tools | Options | General
More info in this article:
Failures caused by Name Auto-Correct
at:
http://allenbrowne.com/bug-03.html

BTW, did you create this form by copying and pasting in the Database window?
I recently had an experience where the database corrupted a form by doing
that, and the names were consistent between the Database Window and
CurrentProject.AllForms on the one hand, and the MSysObjects and
Documents!Forms collections on the other.
 
G

Guest

Arvin, I tried saving as a text file as per your instructions but got a
Visual Basic error - "Compile error: Argument not optional."
 
G

Guest

Allen, I ran your SQL code but my form wasn't listed under any other name.

The corrupted form was originally created by saving an existing form under
another name, but behaved itself for several days after that.

I don't quite follow what you said in your last sentence. Please clarify.
 
A

Allen Browne

Okay, if the form worked for several days, my last comment is not relevant.
(It referred to a case where I recently saw the different ways of listing
forms in Access showing different lists, which indicates a corruption, i.e.
an internal inconsistency in how Access is managing the database.)

I take it from your reply to Arvin that you were not able to get the
SaveAsText to work?

You did make sure the Name AutoCorrect boxes are unchecked under:
Tools | Options | General
 
G

Guest

Nope, SaveAsText just gave the error I quoted. I turned off Name Autocorrect
as you recommended.
 
G

Guest

I simply copied the code from your post and then inserted the real form name,
so all your commas remained intact.
 
D

Dirk Goldgar

David Anderson said:
Arvin, I tried saving as a text file as per your instructions but got
a Visual Basic error - "Compile error: Argument not optional."

Arvin made a small mistake. Don't use the leading question mark for
this. Just enter:

Application.SaveAsText acForm, "FormName", "C:\Temp\FormName.txt"

Note: the above will probably be wrapped by the newsreader, but it
should all be entered on one line. Also, replace "FormName" with the
name of your form, and replace "C:\Temp" with the path to whatever
folder you want the text version of the form to be saved into.
 
G

Guest

Dirk, I ran this code again without the leading question mark, but this time
I got a different VB problem - "Run-time error ' 2950': Reserved Error".
 
A

Arvin Meyer [MVP]

I just created a dummy form named Form1, saved it and used the following in
the debug window:

Application.SaveAsText acForm, "Form1", "C:\Temp\Form1.txt"

It worked perfectly. There is no error number 2950 in Access, so I suspect
you may have another problem. Make absolutely sure that "C:\Temp\" is a
valid path. If you don't have the "Temp" folder on your C: drive, or you
don't have permissions on it, VBA will throw an unexpected error, (which is
what you are seeing.)
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
G

Guest

Arvin, I tried this code on another form and it worked fine. I only get Error
2950 (a VB error, not an Access error) when I try to save the corrupted form
- a problem that may well be due to the nature of that corruption.

Many thanks for your attempts to help (and to Allen and Dirk), but on this
occasion I think that my experience is simply an encouragement to continue
making backups!
 
A

Allen Browne

That conclusion sounds right to me, David.

You do realize you can create a new (blank) database, import all the other
objects, and then import that bad form from a backup?
 

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