Solved

form closes without prompt

Posted on 2014-12-28
9
163 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

910 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

21 Experts available now in Live!

Get 1:1 Help Now