Error Recovery

jeff_i

Registered User.
Local time
Today, 09:53
Joined
Jan 24, 2003
Messages
50
I currently have a macro which is run nightly via a windows scheduled task, the macro imports a couple of text files and makes various updates based upon the new text files. Currently the macro contains about 53 steps, most of which are running action queries.

I would like to convert the macro over to VB and add some type of error recovery; I am not sure how to go about adding the error recovery?

I thought about first making copies of the tables then on error restoring the tables, then sending an alert email. Any suggestions would be appreciated
 
print sub AFormName()

On error goto Error_Exit

code here

Normal_Exit:
Exit sub

error_exit:
msgbxo --your error message--
exit sub

end sub

Function error trapping is similar.
 
I Understand but?

llkhoutx

First thanks for responding to my question, I understand what your saying. But my problem is more along the lines of if say the procces half way through and something fails (append query can't append records due to key violation etc) Somehow I would need to recovery from this and either capture the records in error and continue or revert to the data from before the update.

I would like to make this so it can happen unattended and I only need to look at if I get some type of message. My problem is when the update process does not complete, if the update doesn’t happen the users wont have any "real" problems however if the update stops in the middle they will
Thanks again
 
You've hit the tip of an iceberg. As you can imagine there are all sorts of permutations.

Another approach is to create a table to which you add an appropriate record each time there is an error and resume/exit.

tbErrorLog
ID
iErrorNumber(integer)
iErrNumber (Err.Number)
sErrDesc(Err.Description)
sForm (text name of form where error occurs)
sModule(module name where error occurs)
sErrDescription (your description of error)
dtError (date and time of Error)
sEser(text user name)
sPC(text machine name)

-code to create an error log

dim db as database
dim rs as recordset
set db=currentdb
set rs=db.openrecordset("tbErrorLog",dbopendynaset)
rs.addnew
rs!iErrorNumber = 'You generate a descriptive error number"
rs!sErrNumber=err.number

add whatever you want

etc.
rs.update
rs.close
set rs=nothing
set db=nothing

Some errors are fatal, some are not. If it's fatal, after adding the trapped error record, "Exit Sub", otherwise "Resume Next".

You can view the table, as required or periodically, in a variety of ways. My experience is, each user will generate user specific errors. hence, tracking the User and the PC he/she's using.

It's tough to decide what to do with a standalone/unattended program. That's your call.

Hope the foregoing gives you some more ideas.
 
Last edited:
Thanks Again

llkhoutx

Once again thanks for you input, I can't say I am sure what I will do. I am wondering if I am even going in the right direction, maybe I should be looking into streamlining the number of steps I have, I am not sure that running so many queries is the right approach. Something to think about
 

Users who are viewing this thread

Back
Top Bottom