Solved

show form before quitting

Posted on 2013-01-16
8
221 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
  • 4
  • 3
8 Comments
 
LVL 39

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
 

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 61

Accepted Solution

by:
mbizup earned 500 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

758 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

20 Experts available now in Live!

Get 1:1 Help Now