Results 1 to 6 of 6

Thread: It is possible to save changes before a program shuts down like on an error?

  1. #1

    Thread Starter
    Addicted Member Eric_B's Avatar
    Join Date
    May 2001
    Location
    home sweet home
    Posts
    130

    It is possible to save changes before a program shuts down like on an error?

    It is possible to save changes before a program shuts down like on an error?


    Thanx

  2. #2
    Fanatic Member
    Join Date
    Jul 2001
    Location
    London UK
    Posts
    671
    Why is the program shutting down? Is it an unhandled error in your app. or a system error?

  3. #3
    Hyperactive Member AAG's Avatar
    Join Date
    Aug 2000
    Location
    United States
    Posts
    411
    During your programs operation, you could put

    VB Code:
    1. Private Sub testfunc()
    2. On Error goto ErrCatch:
    3.  
    4. 'Code Goes Here
    5.  
    6. ErrCatch:
    7. 'Enter Code to Save Data
    8. Msgbox "An error has occurecd", vbexclamation, "Error"
    9. End Sub
    This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)

  4. #4

    Thread Starter
    Addicted Member Eric_B's Avatar
    Join Date
    May 2001
    Location
    home sweet home
    Posts
    130
    at the begining of every function and sub?

  5. #5
    Hyperactive Member AAG's Avatar
    Join Date
    Aug 2000
    Location
    United States
    Posts
    411
    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:
    1. Private Sub ErrTest ( )
    2. On Error Goto ErrCatch:
    3.  
    4. 'code goes here
    5.  
    6. ErrCatch:
    7. DisplayError
    8. end sub

    VB Code:
    1. Public Sub DisplayError()
    2. 'Code to save data
    3. 'display msgbox
    4. End Sub
    This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)

  6. #6
    New Member
    Join Date
    Jul 2001
    Posts
    4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width