Recordsource of a form

K

Kaz G

I changed the recordsource of a form from a query to a table. I am now
unable to open the form. I have tried to set the recordsource of the form in
code but Access does not reconise the name of the form, in fact the form
appears to be in the database in name only, I am unable to view, copy or edit
it. Any ideas before I start to recreate the form again apart from make a
copy prior to any changes!!
 
A

Allen Browne

Kaz, the form may be corrupted.

In the Immediate Window (Ctrl+G), try this:
? CurrentProject.AllForms("Form1").Name
replacing Form1 with the name of your form.
If that works, try this (it's one line):
? DLookup("Name", "MSysObjects",
"(MSysObjects.Name = 'Form1') AND (MSysObjects.Type = -32768)")

If one works and not the other, you have a fairly unusual type of
corruption, where the 2 canonical lists of objects in the database are out
of sync. Best solution is to create a new (blank) database, import all the
*other* objects, and then import the bad form from a backup.

If both these expressions work fine but you don't have a backup, you could
try exporting the form to a text file:
SaveAsText acForm, "Form1", "C:\MyFolder\Form1.txt"
Then import it from the text file into you new blank database:
LoadFromText acForm, "Form1", "C:\MyFolder\Form1.txt"

If this is Access 2007, and you have a table/query with the same name as the
form, it might be this issue:
http://support.microsoft.com/kb/926700

Other general suggestions on recovering a problem database:
http://allenbrowne.com/recover.html
 

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