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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File copy (while .mdb is open 6

Status
Not open for further replies.

claudebo

Programmer
May 17, 2002
8
US
Hi
I there any way to make a copy of an Original.mdb file while Original.mdb is open.

I tried :
Dim SourceFile, DestinationFile
SourceFile = "C:\Original.mdb" ' source file name.
DestinationFile = "C:\Backup.mdb" ' target file name.
FileCopy SourceFile, DestinationFile ' source to target.

but that does not work (access 97).
Any Ideas
Claude

 
I'd have bet money you were wrong saying that code doesn't work. Of course, you were correct! It won't let you do that.

Drop the following code into a Module. It WILL work.

Function BackMeUp()
Dim SourceFile, DestinationFile
Dim DB As Database
Dim CHNL As Integer
Set DB = Currentdb
SourceFile = DB.Name ' source file name.
DestinationFile = "C:\Backup.mdb" ' target file name.
CHNL = FreeFile
Open "C:\Junk.bat" For Output As #CHNL
Print #CHNL, "COPY " & Chr(34) & SourceFile & Chr(34) & " " & Chr(34) & DestinationFile & Chr(34) & " /Y"
'FileCopy SourceFile, DestinationFile ' source to target.
Close #CHNL
Shell "C:\Junk.bat", vbNormalFocus
' Shell "C:\Junk.bat", vbHide
End Function
 
Hi Kotaro24,

This is a fabulous bit of coding, sorry I can only give you one star it certainly deserves the maximum 5.

Thanks a lot

Bill
 
Kotaro24

I cannibalized your code.

I wanted to copy the backend and not the front end (current db), so I just wrote a static bat file with the contents of your junk.bat, then used the shell command you had.

Think it will work like a charm - haven't tested it completely yet, but I'm confident it will.

Star for the code that I used.

Thanks,

SiberBob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top