william007,
why do you want to backup while the db is open? any particular reason?
Main Topics
Browse All TopicsI have a button in the form of the current access file. What I want to do is when the user click on the button,
triggered the vba to backup current access file. But since the file is currently open, is this possible? If yes, may I know how to do it with vba?
I have tried two methods but failed:
1) Use copytofile method, but I get permission denied due to file open;
2) Use dbengine.compactdatabase method, but it also has problem if the file is open.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi FileSystemObject has done the job:)
The reason is, after backing up the database, the nextstep is to delete the user table from current database and replace with new set of table from the other mdb file. But before replacing the table, I will checked whether there is any opened table.
Although I have basically solve the problem, but i will still rewarded the point if there is other useful comment, thanks:)
Thanks Vee_Mod:)
Hi scampgb,
>>I'm still not sure how safe it is to copy a currently-open database file though.
What I do is before doing the copy, I will make sure two prequisites was fulfilled(using vba code):
1)Only 1 person is using the db;
2)All the objects (ie, forms, table, etc) has been closed, and only 1 form opened, which is the form that run the file copy code. (The form doesn't make use of any table).
This is to ensure all the changes that user made have been committed to the database before making the file copying. (The file copy code will run regardless of this two prerequisites, they are put in place just to ensure things that done by user have already been saved before copying) :)
Business Accounts
Answer for Membership
by: scampgbPosted on 2007-07-11 at 05:01:13ID: 19461671
You won't be able to make a copy of the file, or compact it, while it's currently open.
/modules/m dl0020.htm as an example.
However, you could get Access to call a shell script, close the database, compact/copy the database and then re-open the file.
Take a look at http://www.mvps.org/access