By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,688 Members | 1,153 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,688 IT Pros & Developers. It's quick & easy.

Need vb codes for auto backup of backends

P: n/a
Folks,
I am not very good at coding here, see if anyone would like to
help me on this. Upon opening of an Access DB, the switchboard is
launched. I want to code the OnOpen Event, the backend database (with
its location) is copied to another location for backup if this is the
first time of the day this database was accessed, else do not launch
the backup.

Is this possible with MS Access? without using the task manager or
another program?

Perry

May 21 '07 #1
Share this Question
Share on Google+
7 Replies

P: n/a
On May 21, 1:42 pm, perry...@yahoo.com wrote:
Folks,
I am not very good at coding here, see if anyone would like to
help me on this. Upon opening of an Access DB, the switchboard is
launched. I want to code the OnOpen Event, the backend database (with
its location) is copied to another location for backup if this is the
first time of the day this database was accessed, else do not launch
the backup.

Is this possible with MS Access? without using the task manager or
another program?

Perry
is this a multi-user database or single user?

May 21 '07 #2

P: n/a
On May 21, 1:42 pm, perry...@yahoo.com wrote:
Folks,
I am not very good at coding here, see if anyone would like to
help me on this. Upon opening of an Access DB, the switchboard is
launched. I want to code the OnOpen Event, the backend database (with
its location) is copied to another location for backup if this is the
first time of the day this database was accessed, else do not launch
the backup.

Is this possible with MS Access? without using the task manager or
another program?

Perry
FileSystemObject.CopyFile "c:\path\file.mdb", "c:\backup\path\", True

True says to overwrite if the file already exists in the backup
location.
Trailing back slash on backup path is required unless you specify a
new file name.


May 21 '07 #3

P: n/a
David,
Thanks for your reply. This is a multi user environment.
How do I set it to happen daily? The way you have it here, will copy
if the file already exists in the destination, so every open of the
database will make a copy? What if I just want this to happen once a
day?

Perry

May 21 '07 #4

P: n/a
ARC
If you only want it once a day, you'll need a new field in your shared
database. If you have a config or global options table, you could add a new
field, something like AutoBUDate. Then whenever you run the backup code, set
the AutoBUDate to today's date. So if that date = today, then don't run the
backup code.
<pe******@yahoo.comwrote in message
news:11**********************@y2g2000prf.googlegro ups.com...
David,
Thanks for your reply. This is a multi user environment.
How do I set it to happen daily? The way you have it here, will copy
if the file already exists in the destination, so every open of the
database will make a copy? What if I just want this to happen once a
day?

Perry

May 22 '07 #5

P: n/a
Public Sub Backup()
Dim MyObject As Scripting.FileSystemObject
Set MyObject = New Scripting.FileSystemObject

Dim strDate As String
Dim strDB As String
Dim strDBReplace As String
Dim strDBName As String
Dim strDBPath As String
Dim strBUDB As String

strDB = CurrentDb.Name

strDBName = Dir(strDB) 'full DB path and name
strDBPath = Replace(strDB, strDBName, "") 'remove DB name from path

strDate = Replace(Date, "/", "_") 'underscore date
strDBReplace = Replace(strDBName, ".mdb", ("_" & strDate)) 'add date
to DB name
strBUDB = strDBPath & "backup\" & strDBReplace 'path + backup dir +
new name

MyObject.CopyFile strDB, strBUDB, True

End Sub

May 22 '07 #6

P: n/a
On Tue, 22 May 2007 08:31:15 -0500, "ARC" <an**@andyc.comwrote:
>If you only want it once a day, you'll need a new field in your shared
database. If you have a config or global options table, you could add a new
field, something like AutoBUDate. Then whenever you run the backup code, set
the AutoBUDate to today's date. So if that date = today, then don't run the
backup code.
You could examine the date stamp of the backed up file and if it is equal to
today(), then don't run backup code.

Chuck
>
<pe******@yahoo.comwrote in message
news:11**********************@y2g2000prf.googlegr oups.com...
>David,
Thanks for your reply. This is a multi user environment.
How do I set it to happen daily? The way you have it here, will copy
if the file already exists in the destination, so every open of the
database will make a copy? What if I just want this to happen once a
day?

Perry
May 22 '07 #7

P: n/a
On May 22, 2:03 pm, Chuck <libb...@schoollink.netwrote:
On Tue, 22 May 2007 08:31:15 -0500, "ARC" <a...@andyc.comwrote:
If you only want it once a day, you'll need a new field in your shared
database. If you have a config or global options table, you could add a new
field, something like AutoBUDate. Then whenever you run the backup code, set
the AutoBUDate to today's date. So if that date = today, then don't run the
backup code.

You could examine the date stamp of the backed up file and if it is equal to
today(), then don't run backup code.

Chuck


<perry...@yahoo.comwrote in message
news:11**********************@y2g2000prf.googlegro ups.com...
David,
Thanks for your reply. This is a multi user environment.
How do I set it to happen daily? The way you have it here, will copy
if the file already exists in the destination, so every open of the
database will make a copy? What if I just want this to happen once a
day?
Perry- Hide quoted text -

- Show quoted text -
I tried all these methods, they don't quit work for me... may be I am
a little dumb on coding...

I put the following code on the OnOpen Event of my Switchboard and re-
open the database, it just flash and went away.

FileSystemObject.CopyFile "C:\tmp\BackEndDB.mdb", "c:\temp\",
True

Why?

I also tried Christian's codes and put it on the SwitchBoard but
nothing happened, silent.

Perry

May 23 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.