[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

form closes without prompt

Posted on 2014-12-28
9
Medium Priority
?
170 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 1000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 34

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 1000 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
Dale Fye earned 500 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 500 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

650 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