copying database to a directory

willem

Registered User.
Local time
Today, 22:28
Joined
Jun 17, 2001
Messages
41
Is it possible to open a database (original).
open a form
click on a button, the database (original) closes and gets copied and stored somewhere and then the original is reopened
Would it happen in vba or vb or something else?


Willem
 
The simplest solution might be to write a .BAT file to:

1) COPY the original .MDB to a backup .MDB
2) Open the original .MDB with Access

Caveat: If this will run by any of several different folks, MSACCESS.EXE may be installed in a different folder for each person. If you're the only one to perform this backup function, No worries.

HTH,

Ken Grubb
Burlington, NC, USA
 
Can i call the .bat file in access and how.
Actually i don't know what a bat file is.

It is a single user db. I read somewhere that compactdatabase method could be used to make a copy of a db but I can't find much on that.
 
A .bat file is simply a DOS Batch file. Really, it's nothing more than a plain text file with a .bat extension.

Since it's a single user DB, use any text editor (Notepad, Wordpad, etc) to create something like this:
********* Start of the .bat file *********
COPY C:\Path To Your Database\DataBaseName.MDB C:\Path To Your Backup Database\BackupDataBaseName.MDB
"C:\Path To MS Office\MSACCESS.EXE" "C:\Path To Your Database\DataBaseName.MDB"
********* End of the .bat file *********
Save it as BACKUP.BAT (The two lines may wrap when displayed in Access Forums. Those in your .bat file should each be on it's own line. Don't wrap 'em with hard page breaks. And you don't need the lines with asterisks.)

You probably want to have it Run Minimized and Close On Exit (Right Click the .bat file in Windows Explorer, and go Properties, Program Tab, select Run Minimized and Close on exit) if you're in Win9x/Me.

BTW, what version of Windows are you running? If you're using WinNT or Win2K, I believe those options are automatic, and if you're running WinNT or Win2K you can make it a .CMD extension.

Double click on the .bat file from Windows Explorer. Access should open up with your database and there should be a backup copy of your database.

HTH,

Ken Grubb
Burlington, NC, USA


[This message has been edited by Ken Grubb (edited 08-05-2001).]

[This message has been edited by Ken Grubb (edited 08-06-2001).]
 
Hi,

I tried this code to backup my d/b

copy C:\Mark\A-levels\Computing\A-Level\stsc_db_17.01.02.mdb D:\database.mdp
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "C:\Mark\A-levels\Computing\A-Level\stsc_db_17.01.02.mdb"

But it gives an Incorrect Function when I run it,


Why would this be

Mk
 
If it's a batch file all you need is:

copy c:\YourPath\YourDBName d:\NewPath\NewDBName

Type this in a notepad file. Now rename the text file from text.txt (or whatever) to CopyMyDB.bat. If you click on it, the copy will execute.

Use can execute the batch file via VBA by using the "Shell" command (look this up in VBA help facility.

Good luck,

Dave
 

Users who are viewing this thread

Back
Top Bottom