It is possible to save changes before a program shuts down like on an error?
Thanx
It is possible to save changes before a program shuts down like on an error?
Thanx
Why is the program shutting down? Is it an unhandled error in your app. or a system error?
During your programs operation, you could put
VB Code:
Private Sub testfunc() On Error goto ErrCatch: 'Code Goes Here ErrCatch: 'Enter Code to Save Data Msgbox "An error has occurecd", vbexclamation, "Error" End Sub
at the begining of every function and sub?
if every sub has a probably cause to produce an error then yes. i would create a function to save the data a produce the msgbox to save on code type, for example
VB Code:
Private Sub ErrTest ( ) On Error Goto ErrCatch: 'code goes here ErrCatch: DisplayError end sub
VB Code:
Public Sub DisplayError() 'Code to save data 'display msgbox End Sub
It might be quite dangerous doing this, I wrote a excel macro which saved the document when an error occurred. Unfortunately it was in a template and when I wrote it and couldn't save itself to the correct directory as it was written to save the doc based on the document not the template. This led to it saving itself with an error status in the macro which, when I tried to open it again Dr. Watsonned Excel. I can't remember how I got round it now, I think I automatically closed the app without saving if this happenned probably the safest thing to do in the circumstances.