error checking

  • Thread starter Thread starter Troy
  • Start date Start date
T

Troy

I have a form that enters data into a table(table1). I would like to add
some code to a button that would append that data to another table(table2).
I know how to create a append table, but I would like some assurance that
when I append that all the data would not be lost. Is there some error code
I can use that would assure me of this? What is the best approach?
 
Troy said:
I have a form that enters data into a table(table1). I would like to add
some code to a button that would append that data to another
table(table2).
I know how to create a append table, but I would like some assurance that
when I append that all the data would not be lost. Is there some error
code
I can use that would assure me of this? What is the best approach?

The best approach when dealing with critical data is to back it up first.
Leave the backed up table alone until you're certain it has all appended ok.
Then it can be either be archived into a new db file or deleted.

That said, the approach I would take to appending the data is to use the
Execute method inside an error-trapped procedure, like this:

On Error Goto Trap

CurrentDb.Execute "MyAppendQuery", dbFailOnError

ExitPoint:
Exit Sub

Trap:
MsgBox Err.Description
Resume ExitPoint
 
thanks! Hey if I want to delete the data from the table one after I've ran
the append would I insert it in this code as well?
 
Troy said:
thanks! Hey if I want to delete the data from the table one after I've
ran
the append would I insert it in this code as well?

Yes you could, because if the append causes an error somehow, the delete
code (on the next line) will not run, as the procedure will have been exited
once the error has been trapped.
 
Back
Top