Command Button Opens the Wrong Form

G

Guest

When I create a command button to open any of my forms, the wrong from is
opened. No matter whay I've tried (Macros/Wizard/Code) a form that has
actually been deleted opens up. When I switch to design view and then back
to form view, the correct from is displayed.

Im at a total loss.
 
A

Allen Browne

Anna, if a deleted form is being displayed, you have a corruption in your
database.

To fix, it try this sequence:

1. Make a backup of your MDB file, so you get multiple chances to fix it.

2. Open it, and uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html

3. Compact the database to get rid of the Name AutoCorrect stuff:
Tools | Database Utilities | Compact

4. Close Access. Decompile 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"

5. Open Access, and compact again.

6. Create a new blank database.
Uncheck the Name AutoCorrect boxes.
Import everything from your old database:
File | Get External | Import

7. Press Ctrl+G to open the Immediate Window.

8. Open a code window.
Choose References from the Tools menu.
Uncheck any references you do not need.
For a list of the ones you typically need in your version of Access, see:
http://allenbrowne.com/ser-38.html

9. Still in the code window, choose Compile from the Debug menu.
Fix any errors, and repeat until it compiles okay.

At this point, you should have a database where the name-autocorrect errors
are gone, the indexes are repaired, inconsistencies between the text- and
compiled-versions of the code are fixed, inconsistencies between the
AllForms collection and the forms in MSysObjects are gone, reference
ambiguities are resolved, and the code syntax is compilable.
 
G

Guest

Allen
Thanks for your quick reply, but unfortunately I'm still having the problem.
Any more suggestions?
 
A

Allen Browne

Anna, I don't understand how you can have a deleted form show up in a
database that never had the deleted form in the first place.
 
G

Guest

I don't either. If I make a new form using the tabular auto form instead of
the datasheet auto form it seems to work ok. This may just have to be a
workaround.

Thanks for the help
 

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