Solved

form closes without prompt

Posted on 2014-12-28
9
159 Views
Last Modified: 2014-12-29
The application I am developing has a very annoying problem. One of the forms, frmJobs, closes itself from time to time when I try to edit, or close another form. There is no link between the forms, each is standalone though they do draw from the same tables in a linked database. I have no idea why. E.g. a few minutes ago I opened another form in Edit mode and the instant I did the Close Event of frmJobs executed and the form closed. It doesn't happen all the time, just often enough to be annoying. Any suggestions?
0
Comment
Question by:Rob4077
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 33

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 250 total points
ID: 40521224
You possibly have a code like

DoCmd.Close

This closes whatever has focus.

Change this line specifying the name of the form you want to be closed.

expression .Close(ObjectType, ObjectName, Save)

DoCmd.Close acForm, "Order Review", acSaveYes

A AcCloseSave constant tha specifies whether or not to save changes to the object. The default value is acSavePrompt.

Mike
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40521242
you should explicitly identify the form you want to close

avoid using this command to close your form
 docmd.close

a generic way of doing this is

docmd.close acform, me.name
0
 

Author Comment

by:Rob4077
ID: 40521318
That was my first thought but I have searched all my code for close commands but that's not the problem.  Last time this happened I right clicked on another form and chose to open it in design mode. As soon as I did frmJobs closed.  No vba was even triggered.
0
 
LVL 33

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 250 total points
ID: 40521396
Last thing I will suggest is:

- On the File tab, click Options.

In the Access Options dialog box, click Current Database.

Under Application Options, select the Compact on Close check box.

To see if it corrects the problem. Close the application and restart it.

Mike
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 125 total points
ID: 40521577
is there a chance that the form is not closing, but being hidden?  You might want to check to see if there are any lines like:

me.visible = False

either in the form that is closing, or in the other form that is being popped up.  Because this is only happening occassionally, I would expect that you would find this inside some form of If/Then statement because it is probably associated with some logic statement.

Dale
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 125 total points
ID: 40521739
I would suggest you avoid the Compact on Close. Instead, just compact it as needed.

You may also have corruption creeping into your database. Make a backup, then do this:

1. Compact the database
2. Compile your code - from the VBA Editor window click Debug - Compile. Fix any errors, and continue doing this until the Compile menu option is disabled.
3. Compact again.

You might also need to Decompile your database. To do that, create a new Shortcut with this as the Target:

"Full path to msaccess.exe" "full path to your database" /decompile

Run that shortcut, then run the 3 steps above again.

You might also consider creating a new, blank database and importing everything from the old db into the new one.

Finally, be sure your Windows and Office installations are fully up to date.
0
 
LVL 33

Expert Comment

by:Mike Eghtebas
ID: 40521751
Hi Scott,

re:> I would suggest you avoid the Compact on Close

What is the problem with using Compact on Close?

Thanks,

Mike
0
 
LVL 84
ID: 40521769
One of the more serious issues is that anytime you compact a database, you run the risk of corrupting it irretrievably. To me, it's just not worth the risk.

ConC also impacts the current database only. If you're running a split configuration (as you should be), then you're only compacting the FrontEnd, not the BackEnd (which generally needs compacting much more often than a FE).

It can actually make things run a bit slower, since compacting forces Access to rebuild indexes when things restart. Granted that on most modern machines that would probably not be much of an impact, but if there's no need then why do it.

The most concerning to me, however, is that if your database requires compacting each time you close it, then you have issues that eventually will lead to serious troubles. You should instead correct the issues which are causing the corruption instead of ignoring them. It's sort of like turning up the volume in your car when the brakes start to squeal, instead of fixing the brakes :)
0
 

Author Comment

by:Rob4077
ID: 40523175
Thanks for your comments.

I think most suggestions are sensible and valid and so I will share points, but Scott's comments were the only ones I had not tried - I have now. I won't know if it's fixed the problem for some time as it was a random problem but hopefully it will be ok now. This has been a strange problem for me.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now