Solved

form closes without prompt

Posted on 2014-12-28
9
168 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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 48

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 85

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

724 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