Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

backup an access DB 3

Status
Not open for further replies.

micky500970

Programmer
Jul 9, 2004
81
0
0
GB
Hello,

I would like to create a program that could create a copy of our access DB and store it in another directory. I would like to do this three times a day so I would somehow need to check if the DB is in use.

I was hoping to get some advice on how I should approach this as the DB is very important and I would hate to destroy it :O)

thanks in advance

Mick
 
I'm doing the same thing using the FileSystemObject.

Code:
Dim fso as FileSystemObject
set fso = new FileSystemObject

fso.copyfile (source, destination,overwrite (True/False))

set fso = nothing

Hope this helps,

Patrick

 
Hi,

You can use FileCopy. It will return a trappable error if the file it is attempting to copy is open.

It took me 22 seconds to copy a 320md DB.

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
Patrick's answer is about twice as fast as mine.

If you put in a clause into his code saying:
Code:
If fso.FileExists("Database_to_Copy.ldb") = False Then
'Code to copy the file...
That will check if the DB is open already before you would try and copy it.

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
Hi guys,

I cannot get it to work. i have made the necessary reference.

Dim fso As FileSystemObject
Set fso = New FileSystemObject



fso.CopyFile("c:\rp\db1.mdb","c:\db-backup",true)

I get the following error:

compile error, expected =

any help will be much appreciated

Mick
 
Change this:

fso.CopyFile("c:\rp\db1.mdb","c:\db-backup",true)

to this:

fso.CopyFile "c:\rp\db1.mdb","c:\db-backup",true

Note the removal of the (). You are trying to call a function when you include them, so the compiler is expecting the =.
 
Great!

But now i get a permission denied error.
I have checked the C drive and everyone has full control.
i have also replaced the DB file with a text file and still get the permission error.
It is one of those nights.


mick

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top