?
Solved

show form before quitting

Posted on 2013-01-16
8
Medium Priority
?
269 Views
Last Modified: 2013-01-19
hey guys,

i've got a frmSynchronise that i open as a hidden form when the DB opens. when i close the DB, i want to display the form and then synchronise the replicas. what this does is that when the user sees the open form, he / she knows that the DB is syncing and thus taking awhile to quit instead of thinking that the programme is lousy.

however, i can't get the form to become visible regardless what i try

Private Sub Form_Close()

Me.Visible = True
DoEvents 'in an attempt to make the form visible
Me.Repaint 'in an attempt to make the form visible
Call GeneralRefactoring.SynchroniseBEReplicas
Application.Quit
'Sleep 1000

End Sub

Open in new window


is it because i'm putting it in the form close event and thus it cannot display? but when i debug and step through, i indeed CAN make the form visible. could yall help me out please? thanks!!
0
Comment
Question by:developingprogrammer
[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
  • 4
  • 3
8 Comments
 
LVL 40

Expert Comment

by:als315
ID: 38786008
If this form is invisible, why code is in Close event for this form? Try to make form visible on form, where you are closing DB.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38786428
I think that you are trying to make this happen too late - and you are giving Access conflicting instructions.

DoCmd.Quit tells Access to shut down.  As it does so, it closes all objects... so this is not a good time to tell it to open (or show) a form.

A workaround if you really need to see the form might be to open a separate database whose sole purpose is to display that form, synchronize the databases (you'd have to adjust the path of the replica since your synchronization code currently assumes that the current database is the replica) and shut itself down.  You could do that from the close event:

Private Sub Form_Close()

Application.FollowHyperlink "YourPath\YourDB.mdb"

End Sub

Open in new window

0
 
LVL 61

Expert Comment

by:mbizup
ID: 38786498
Another (easier) solution might be to create a separate form to handle the synchronization.

Then in the close event:

Private Sub Form_Close()

DoCmd.OpenForm "YourSychronizationFormName", WindowMode := acDialog
Application.Quit
'Sleep 1000

End Sub

Open in new window


And place your synchronization code in "YourSychronizationFormName".

The acDialog window mode option halts code execution in the close event until YourSychronizationFormName closes - so the Application.Quit code won't run until the user closes YourSychronizationFormName, or the code in that form self-closes it.
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:developingprogrammer
ID: 38792376
guys, thanks for your great responses.

ok i've done quit a bit of messing around and testing, and here's my line of code.

If Environ("Username") <> "inactive" Then
    DoCmd.OpenForm "frmSynchronise"
    DoEvents
    Call GeneralRefactoring.SynchroniseBEReplicas
    DoCmd.Quit
End If

Open in new window


everything works perfect when i'm closing my form and this code is triggered in the on close event of my main form. however when i hit the x on the top right of the screen to close the access application (not the form), my frmSynchronise does not load up until i can see the words on it. here are the pictures below. how can i get the form to load fully so the user can see the words on the form and know what's going on when they hit alt f4 or the top right x? thanks guys!!

p.s. oh yes guys and i can't use acdialog cause that would stall the code execution until user closes the form or does something. so acdialog is sadly ruled out = (((
when i close the whole application alt f4 or click x top right cornerwhen i close the form
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38792519
My gut feeling here is that you are trying to do the impossible.

You are trying to keep a form open while Access is actively trying to close all objects in the current database (this is what happens when you click the application's "x" button).

You can try the approach I suggested earlier of placing this form in a separate database designed to run the synchronization, or research methods for disabling the Application's "X" button (there are methods out there, but I personally would stick to the second database approach).
0
 

Author Closing Comment

by:developingprogrammer
ID: 38796389
niaks, doing a separate database is a bit too much for me to do so what i did was i just put in the captions of the form "Database syncing to network....." so even though the form is blank they will still see the title of the form and can gather something from there. thanks mbizup and als315!!!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38796433
That is a really good workaround!

If you can't be with the form you love, love the one you're with!
0
 

Author Comment

by:developingprogrammer
ID: 38796459
Hahahaha that's classic!! Going in my diary... = PP = ))
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

741 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