Saving DB to flash drive

  • Thread starter Thread starter Rocky
  • Start date Start date
R

Rocky

hello all,
Please can someone tell me. how do you save the entire
database to a flash drive with code.
I use the flash drive to carry files to and from work so
that i can work on them at home.
but i can not find a way to do this with an access db.
Transferdatbase just let you transfer table, queries ect
not the whole db.
I can use exployer ie drag and drop but i would like to
have a button on a form and do it with code.
can this be done.
please note..i am fairly new to access.
thank you in advance.
Rocky Rhodes
 
You cannot (or, more precisely, should not) copy an open database as it may
end up in an inconsistent state. Most of the file copying methods will not
allow you to copy a file that's in use for this reason.

Copying through Explorer is the preferred way.
 
Rocky,

You can call a batch script using a command button that would copy your file. A batch file is coded using the DOS language.


STEP 1) Copy the following, open Notepad, and paste the code inside. Save the file as Backup.bat and be sure to save it in the same folder as your application.

======== Copy Here =========
@@echo off

echo.
echo ===============
echo STARTING BACKUP
echo ===============
echo Please standby...
ping localhost -n 3 > nul

::Edit the Location for your File and Where to Backup
xcopy /q/y/c/e "C:\Program Files\ApplicationName\ApplicationFile.mdb" "E:\Backups\*.*" > nul

cls
echo.
echo Backup Complete! Standby...
ping localhost -n 3 > nul

======== End Here =========

STEP 2) Copy the following code and paste it into a button's OnClick event:


'=========================================
'DATE:
'AUTHOR:
'COMMENTS:
'
'1) This subroutine launches a MS-DOS
'batch script to perform a backup of
' the application.
'=========================================


'DECLARING VARIABLE
Dim strAppName As String

'INITIALIZING VARIABLE (EDIT THE LOCATION OF THE BATCH FILE IF NEEDED)
strAppName = "C:\Program Files\ApplicationName\Backup.bat"

'CALLING MS-DOS BATCH SCRIPT TO PERFORM APPLICATION UPDATE
Call Shell(strAppName, 1)

STEP 3) Test the button and make sure it works!

Best regards,

Todd
hello all,
Please can someone tell me. how do you save the entire
database to a flash drive with code.
I use the flash drive to carry files to and from work so
that i can work on them at home.
but i can not find a way to do this with an access db.
Transferdatbase just let you transfer table, queries ect
not the whole db.
I can use exployer ie drag and drop but i would like to
have a button on a form and do it with code.
can this be done.
please note..i am fairly new to access.
thank you in advance.
Rocky Rhodes
 
I would like to add that it would probably be much easier to code a simple batch script to backup the file without having to add a button in the program itself. Just place a shortcut to the batch file on your desktop, or a QuickLaunch shortcut--that would accomplish the same thing. Just click the batch script shortcut and your done.

Best regards,

Todd
Rocky,

You can call a batch script using a command button that would copy your file. A batch file is coded using the DOS language.


STEP 1) Copy the following, open Notepad, and paste the code inside. Save the file as Backup.bat and be sure to save it in the same folder as your application.

======== Copy Here =========
@@echo off

echo.
echo ===============
echo STARTING BACKUP
echo ===============
echo Please standby...
ping localhost -n 3 > nul

::Edit the Location for your File and Where to Backup
xcopy /q/y/c/e "C:\Program Files\ApplicationName\ApplicationFile.mdb" "E:\Backups\*.*" > nul

cls
echo.
echo Backup Complete! Standby...
ping localhost -n 3 > nul

======== End Here =========

STEP 2) Copy the following code and paste it into a button's OnClick event:


'=========================================
'DATE:
'AUTHOR:
'COMMENTS:
'
'1) This subroutine launches a MS-DOS
'batch script to perform a backup of
' the application.
'=========================================


'DECLARING VARIABLE
Dim strAppName As String

'INITIALIZING VARIABLE (EDIT THE LOCATION OF THE BATCH FILE IF NEEDED)
strAppName = "C:\Program Files\ApplicationName\Backup.bat"

'CALLING MS-DOS BATCH SCRIPT TO PERFORM APPLICATION UPDATE
Call Shell(strAppName, 1)

STEP 3) Test the button and make sure it works!

Best regards,

Todd
hello all,
Please can someone tell me. how do you save the entire
database to a flash drive with code.
I use the flash drive to carry files to and from work so
that i can work on them at home.
but i can not find a way to do this with an access db.
Transferdatbase just let you transfer table, queries ect
not the whole db.
I can use exployer ie drag and drop but i would like to
have a button on a form and do it with code.
can this be done.
please note..i am fairly new to access.
thank you in advance.
Rocky Rhodes
 
I'm curious, Todd, as to why you're recommending the round about way of
calling a batch file when VBA has a FileCopy command built into it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rocky,

You can call a batch script using a command button that would copy your
file. A batch file is coded using the DOS language.


STEP 1) Copy the following, open Notepad, and paste the code inside. Save
the file as Backup.bat and be sure to save it in the same folder as your
application.

======== Copy Here =========
@@echo off

echo.
echo ===============
echo STARTING BACKUP
echo ===============
echo Please standby...
ping localhost -n 3 > nul

::Edit the Location for your File and Where to Backup
xcopy /q/y/c/e "C:\Program Files\ApplicationName\ApplicationFile.mdb"
"E:\Backups\*.*" > nul

cls
echo.
echo Backup Complete! Standby...
ping localhost -n 3 > nul

======== End Here =========

STEP 2) Copy the following code and paste it into a button's OnClick event:


'=========================================
'DATE:
'AUTHOR:
'COMMENTS:
'
'1) This subroutine launches a MS-DOS
'batch script to perform a backup of
' the application.
'=========================================


'DECLARING VARIABLE
Dim strAppName As String

'INITIALIZING VARIABLE (EDIT THE LOCATION OF THE BATCH FILE IF NEEDED)
strAppName = "C:\Program Files\ApplicationName\Backup.bat"

'CALLING MS-DOS BATCH SCRIPT TO PERFORM APPLICATION UPDATE
Call Shell(strAppName, 1)

STEP 3) Test the button and make sure it works!

Best regards,

Todd
hello all,
Please can someone tell me. how do you save the entire
database to a flash drive with code.
I use the flash drive to carry files to and from work so
that i can work on them at home.
but i can not find a way to do this with an access db.
Transferdatbase just let you transfer table, queries ect
not the whole db.
I can use exployer ie drag and drop but i would like to
have a button on a form and do it with code.
can this be done.
please note..i am fairly new to access.
thank you in advance.
Rocky Rhodes
 
The FileCopy statement will copy any closed file to any destination. You
will not, however, be able to run it from within your app. Checkout
dbMaint, a stand alone compress and backup utility at www.chiselsoftware.com
-Ed
 
Doug,

I have to be honest here--haven't tried the FileCopy function yet. However, I do know how to code batch scripts--that's why I went this route.

Although, I am always open to the idea of using a different approach, especially if its more effecient. Although, according to Ed's reply, it appears that FileCopy cannot be used to copy the file currently open--although I would like to test it myself. In contrast, I have used a batch script to copy an open Access application. Although, I usually instruct the user to wait before starting any read-write actions until the copying is finished.

Best regards,

Todd


I'm curious, Todd, as to why you're recommending the round about way of
calling a batch file when VBA has a FileCopy command built into it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rocky,

You can call a batch script using a command button that would copy your
file. A batch file is coded using the DOS language.


STEP 1) Copy the following, open Notepad, and paste the code inside. Save
the file as Backup.bat and be sure to save it in the same folder as your
application.

======== Copy Here =========
@@echo off

echo.
echo ===============
echo STARTING BACKUP
echo ===============
echo Please standby...
ping localhost -n 3 > nul

::Edit the Location for your File and Where to Backup
xcopy /q/y/c/e "C:\Program Files\ApplicationName\ApplicationFile.mdb"
"E:\Backups\*.*" > nul

cls
echo.
echo Backup Complete! Standby...
ping localhost -n 3 > nul

======== End Here =========

STEP 2) Copy the following code and paste it into a button's OnClick event:


'=========================================
'DATE:
'AUTHOR:
'COMMENTS:
'
'1) This subroutine launches a MS-DOS
'batch script to perform a backup of
' the application.
'=========================================


'DECLARING VARIABLE
Dim strAppName As String

'INITIALIZING VARIABLE (EDIT THE LOCATION OF THE BATCH FILE IF NEEDED)
strAppName = "C:\Program Files\ApplicationName\Backup.bat"

'CALLING MS-DOS BATCH SCRIPT TO PERFORM APPLICATION UPDATE
Call Shell(strAppName, 1)

STEP 3) Test the button and make sure it works!

Best regards,

Todd
hello all,
Please can someone tell me. how do you save the entire
database to a flash drive with code.
I use the flash drive to carry files to and from work so
that i can work on them at home.
but i can not find a way to do this with an access db.
Transferdatbase just let you transfer table, queries ect
not the whole db.
I can use exployer ie drag and drop but i would like to
have a button on a form and do it with code.
can this be done.
please note..i am fairly new to access.
thank you in advance.
Rocky Rhodes
 
Doug,

Here's some information I found about copying files on a Microsoft website:

http://support.microsoft.com/default.aspx?scid=kb;en-us;207703

Respectfully,

Todd
Doug,

I have to be honest here--haven't tried the FileCopy function yet. However, I do know how to code batch scripts--that's why I went this route.

Although, I am always open to the idea of using a different approach, especially if its more effecient. Although, according to Ed's reply, it appears that FileCopy cannot be used to copy the file currently open--although I would like to test it myself. In contrast, I have used a batch script to copy an open Access application. Although, I usually instruct the user to wait before starting any read-write actions until the copying is finished.

Best regards,

Todd


I'm curious, Todd, as to why you're recommending the round about way of
calling a batch file when VBA has a FileCopy command built into it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rocky,

You can call a batch script using a command button that would copy your
file. A batch file is coded using the DOS language.


STEP 1) Copy the following, open Notepad, and paste the code inside. Save
the file as Backup.bat and be sure to save it in the same folder as your
application.

======== Copy Here =========
@@echo off

echo.
echo ===============
echo STARTING BACKUP
echo ===============
echo Please standby...
ping localhost -n 3 > nul

::Edit the Location for your File and Where to Backup
xcopy /q/y/c/e "C:\Program Files\ApplicationName\ApplicationFile.mdb"
"E:\Backups\*.*" > nul

cls
echo.
echo Backup Complete! Standby...
ping localhost -n 3 > nul

======== End Here =========

STEP 2) Copy the following code and paste it into a button's OnClick event:


'=========================================
'DATE:
'AUTHOR:
'COMMENTS:
'
'1) This subroutine launches a MS-DOS
'batch script to perform a backup of
' the application.
'=========================================


'DECLARING VARIABLE
Dim strAppName As String

'INITIALIZING VARIABLE (EDIT THE LOCATION OF THE BATCH FILE IF NEEDED)
strAppName = "C:\Program Files\ApplicationName\Backup.bat"

'CALLING MS-DOS BATCH SCRIPT TO PERFORM APPLICATION UPDATE
Call Shell(strAppName, 1)

STEP 3) Test the button and make sure it works!

Best regards,

Todd
hello all,
Please can someone tell me. how do you save the entire
database to a flash drive with code.
I use the flash drive to carry files to and from work so
that i can work on them at home.
but i can not find a way to do this with an access db.
Transferdatbase just let you transfer table, queries ect
not the whole db.
I can use exployer ie drag and drop but i would like to
have a button on a form and do it with code.
can this be done.
please note..i am fairly new to access.
thank you in advance.
Rocky Rhodes
 
Coincidence... I recently experienced the inability of VBA FileCopy
function to copy an open file, and found a long thread on the topic
using google groups. My solution was to use Windows API "CopyFile"
function. In my case, it is for an often-repeated, mid-day, hot backup
of the database file. Permanent backups are made when the database is
closed.

Doug,

I have to be honest here--haven't tried the FileCopy function yet. However, I do know how to code batch scripts--that's why I went this route.

Although, I am always open to the idea of using a different approach, especially if its more effecient. Although, according to Ed's reply, it appears that FileCopy cannot be used to copy the file currently open--although I would like to test it myself. In contrast, I have used a batch script to copy an open Access application. Although, I usually instruct the user to wait before starting any read-write actions until the copying is finished.

Best regards,

Todd


I'm curious, Todd, as to why you're recommending the round about way of
calling a batch file when VBA has a FileCopy command built into it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rocky,

You can call a batch script using a command button that would copy your
file. A batch file is coded using the DOS language.


STEP 1) Copy the following, open Notepad, and paste the code inside. Save
the file as Backup.bat and be sure to save it in the same folder as your
application.

======== Copy Here =========
@@echo off

echo.
echo ===============
echo STARTING BACKUP
echo ===============
echo Please standby...
ping localhost -n 3 > nul

::Edit the Location for your File and Where to Backup
xcopy /q/y/c/e "C:\Program Files\ApplicationName\ApplicationFile.mdb"
"E:\Backups\*.*" > nul

cls
echo.
echo Backup Complete! Standby...
ping localhost -n 3 > nul

======== End Here =========

STEP 2) Copy the following code and paste it into a button's OnClick event:


'=========================================
'DATE:
'AUTHOR:
'COMMENTS:
'
'1) This subroutine launches a MS-DOS
'batch script to perform a backup of
' the application.
'=========================================


'DECLARING VARIABLE
Dim strAppName As String

'INITIALIZING VARIABLE (EDIT THE LOCATION OF THE BATCH FILE IF NEEDED)
strAppName = "C:\Program Files\ApplicationName\Backup.bat"

'CALLING MS-DOS BATCH SCRIPT TO PERFORM APPLICATION UPDATE
Call Shell(strAppName, 1)

STEP 3) Test the button and make sure it works!

Best regards,

Todd
hello all,
Please can someone tell me. how do you save the entire
database to a flash drive with code.
I use the flash drive to carry files to and from work so
that i can work on them at home.
but i can not find a way to do this with an access db.
Transferdatbase just let you transfer table, queries ect
not the whole db.
I can use exployer ie drag and drop but i would like to
have a button on a form and do it with code.
can this be done.
please note..i am fairly new to access.
thank you in advance.
Rocky Rhodes


**********************
(e-mail address removed)
remove uppercase letters for true email
http://www.geocities.com/jacksonmacd/ for info on MS Access security
 
Note that ms-access 2003 has a option under file->back up database.

This works like a standard file->save as in word etc.

This also checks if any users are in the file.
 
The fact that the file cannot be copied by the FileCopy should be the first
warning that you shouldn't be copying the file! As I said elsewhere in this
thread, copying an open database is a risky proposition, as your copy could
very well be inconsistent.

And while I'm in a pedantic mood, could I suggest that you stop using HTML
for your posts? If you'll notice, my post was 3 KB: your reply to it was 11
KB, due to how much more verbose HTML posts are.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Doug,

Here's some information I found about copying files on a Microsoft website:

http://support.microsoft.com/default.aspx?scid=kb;en-us;207703

Respectfully,

Todd
Doug,

I have to be honest here--haven't tried the FileCopy function yet. However,
I do know how to code batch scripts--that's why I went this route.

Although, I am always open to the idea of using a different approach,
especially if its more effecient. Although, according to Ed's reply, it
appears that FileCopy cannot be used to copy the file currently
open--although I would like to test it myself. In contrast, I have used a
batch script to copy an open Access application. Although, I usually
instruct the user to wait before starting any read-write actions until the
copying is finished.

Best regards,

Todd


I'm curious, Todd, as to why you're recommending the round about way of
calling a batch file when VBA has a FileCopy command built into it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rocky,

You can call a batch script using a command button that would copy your
file. A batch file is coded using the DOS language.


STEP 1) Copy the following, open Notepad, and paste the code inside. Save
the file as Backup.bat and be sure to save it in the same folder as your
application.

======== Copy Here =========
@@echo off

echo.
echo ===============
echo STARTING BACKUP
echo ===============
echo Please standby...
ping localhost -n 3 > nul

::Edit the Location for your File and Where to Backup
xcopy /q/y/c/e "C:\Program Files\ApplicationName\ApplicationFile.mdb"
"E:\Backups\*.*" > nul

cls
echo.
echo Backup Complete! Standby...
ping localhost -n 3 > nul

======== End Here =========

STEP 2) Copy the following code and paste it into a button's OnClick event:


'=========================================
'DATE:
'AUTHOR:
'COMMENTS:
'
'1) This subroutine launches a MS-DOS
'batch script to perform a backup of
' the application.
'=========================================


'DECLARING VARIABLE
Dim strAppName As String

'INITIALIZING VARIABLE (EDIT THE LOCATION OF THE BATCH FILE IF NEEDED)
strAppName = "C:\Program Files\ApplicationName\Backup.bat"

'CALLING MS-DOS BATCH SCRIPT TO PERFORM APPLICATION UPDATE
Call Shell(strAppName, 1)

STEP 3) Test the button and make sure it works!

Best regards,

Todd
hello all,
Please can someone tell me. how do you save the entire
database to a flash drive with code.
I use the flash drive to carry files to and from work so
that i can work on them at home.
but i can not find a way to do this with an access db.
Transferdatbase just let you transfer table, queries ect
not the whole db.
I can use exployer ie drag and drop but i would like to
have a button on a form and do it with code.
can this be done.
please note..i am fairly new to access.
thank you in advance.
Rocky Rhodes
 
Doug,

My appologies--I try not to post my messages in HTML format. Should be okay
now. Otherwise, I concur with your remarks about trying to copy a file while
it is open--you are correct; there runs an increased risk of corrupting data
if there is an interuption to the read-write process. Although, I still
contend it is possible. Otherwise, regarding your pendantic mood, its okay
with me--I do not mind diversity in the least whereas it promotes new ideas
and different ways of thinking.

Respectfully,

Todd Shillam

"Never tell people how to do things. Tell them what to do and they will
surprise you with their ingenuity." --George S. Patton
 
an eye-opener for me, Albert! i use the Backup Database option under Tools,
Database Utilities - never even noticed it's also available under File - "we
only see what we're looking for, not what's there" <g>
 
Back
Top