473,320 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need vb codes for auto backup of backends

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
7 7809
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Beyonder | last post by:
Download MySQL Auto Backup at http://www.swordsky.com to help you. Backups your data automatically from MySQL Database Server Don't worry about your data on MySQL anytime. They will not to be...
2
by: bwmiller16 | last post by:
Anyone - Can anybody tell me where I would find the linux status codes for such udb utilities as backup, etc.? For instance, in my cron job I have: db2 backup database $dir to $BACKUP_DIR...
0
by: Willem | last post by:
Based on MK's TSI_SOON (http://www.trigeminal.com/)I've created a nifty little procedure that - whenever you compact you db you get an incremental backup copy. Given that you have a table with...
5
by: HSP | last post by:
hi. i need to restore an old database. The db was backed up using a DLT drive, using 2 volumes. The content for the tapes was copied to file onto Solaris machine using rsh and dd (for backup...
3
by: rdemyan via AccessMonster.com | last post by:
I just got Access 2003 and have been playing around with it. This whole macro security thing can be a bit annoying. Initially, I was able to link to my backends located on a second computer....
13
by: Javad | last post by:
Hello I know that I should get the information of windows internet connections by using "rasapi32.dll" library, and I also have some sample codes, but I can't make them work. My exact need is to...
0
by: footdoc45 | last post by:
I have been using the Microsoft word backup feature for about 1 year and it always made a backup copy of any file . Starting in January 07 ,the backup stopped. I just recently noticed this and have...
2
by: Chris Gilpin | last post by:
Hey everybody. While running a Query, Access crashed (The 'Send Error Report' window came up) I clicked the option to have access repair and reopen my database. Now in the database folder, I...
2
by: MNNovice | last post by:
I am working on a database on my CD collection using Access 2003. Some of the table structures are given below. Table 1 tblMusicCategory Field 1: MusicCategoryID - Auto Number (PK) Field 2:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.