Solved

form closes without prompt

Posted on 2014-12-28
9
167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 34

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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 34

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
 
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 34

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

730 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