Auto backup if Spreasheet Transfer Fails

J

jeanhurtado

Hi, Folks, I'm Jean and working on my last part of my project (Cycle
Count Dept stand alone system). I'm now programming the backup method
of the database. I have a Excel spreadsheet that it contains the cost
of the part number the dept will use. I have create a table that is
called "Costttable" and a macro that make a transfer from the excel
file to access Costtable. I also have a table that it called
Backupcosttable that it contains the previous contents of the
costtable ( I make update of to cost 2 or 3 times a year). I want to
know how I can code if the spreadsheet transfer fail, the contents of
the backupcosttable transfer to the cost table automatically. Thank
you so much for your effort to help me.




JC
 
T

ti976

costtable ( I make update of to cost 2 or 3 times a year). I want to
know how I can code if the spreadsheet transfer fail, the contents of
the backupcosttable transfer to the cost table automatically. Thank
you so much for your effort to help me.

JC

Error trapping comes to mind. Assuming you run the excel trnsfer in a
vba module, you can write an error trapping rooutine to catch any
error in the transfer and append the old data back:

sub subX()
....
on error goto err_X 'set error trapping
transferdatabase ..... 'code to transfer excel data into table
Costtable
on error goto 0 'turn off error trapping
....'more coding as needed

exit sub

err_X:
'code to clear costtable, ex: currentdb.execute "Delete * FROM
Costtable"
'code to append old data into costtable, ex: currentdb.execute "Insert
into costtable select * from backupcosttable"
'msgbox to informed you of error (optional)

end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top