473,395 Members | 1,624 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,395 software developers and data experts.

Auto backup of both FE and BE using VBA

I have a database that has been split into a FE and BE. Recently we had a user delete 18 months of archived data from the BE. Luckily, IT was able to restore a previous version and retrieve the data. But now I am trying to set up an auto backup of both the FE and BE using an Auto Exec macro and VBA code. I have the code to back up the FE when opened, but I just don't know how to make the BE backup from the same VBA code. Here is the code I am using to back up the FE.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Public Function fMakeBackup()
  4.  
  5.     Dim Source As String
  6.     Dim Target As String
  7.     Dim retval As Integer
  8.  
  9.  
  10.     Source = CurrentDb.Name
  11.  
  12.  
  13.     Target = "S:\Databases\Backups\Open Obligations Action "
  14.     Target = Target & Format(Date, "mm_dd_yy") & ".accdb"
  15.  
  16.     ' create the backup
  17.     retval = 0
  18.     Dim objFSO As Object
  19.     Set objFSO = CreateObject("Scripting.FileSystemObject")
  20.     retval = objFSO.CopyFile(Source, Target, True)
  21.     Set objFSO = Nothing
  22.  
  23.  
  24. End Function
  25.  
  26.  
I am not even going to claim that I figured that code out, I found it out in the interwebby, but could not find a solution to the BE problem. I am not very good with VBA, but I know it's the only way for Access to do an Auto back up. Any help would be greatly appreciated.
Dec 4 '15 #1
3 2058
zmbd
5,501 Expert Mod 4TB
I am surprised that the filescript object was able to copy the open front end, usually, while the front-end, is open, it not be able to be "backed-up" via VBA.

The back-end however, I use:
DBEngine.CompactDatabase zstrData, zstrBkp
Where zstrData is the full name and path of the backend
and zstrBkp is the full name and path of the copy of the backend

Usually, one can do this method; however, I have had occasions where multiple users were in the database and that will cause you issues if the records are locked; thus, you have to error trap for that... at some point, all of the users are logged out and the code will succeed when the last person closes their front-end.

I find it much better to ensure that IT backs-up the folder on a weekly basis. Mission critical information I back-up myself too; however, I don't have as big a harddrive as they have tapes (or whatever is being used now :) ).

As for the front-end - because each user should be using their own copy on their own client-pc, all you should need to do is keep a copy on the network in a restricted read-only directory. There are various threads here on Bytes covering different methods of deploying revised front-ends.

As for being able to delete the data...
+ If the user is in the tables, slap their fingers. They should never be directly using the tables.
+ If your table relationships are set up to enforce with Cascade delete option... this is why I never use that option. The parent cannot be deleted so long as there are related child record; thus, without the cascade delete, the child records are more difficult to remove (not impossible, just takes a bit more effort).
+ Batch delete... in the forms, I usually have the user enter a random 3 character string, or their "PIN" to confirm batch deletes. Often, if it's a lot of data, I'll export it to a second database named: {queryname}_{date}_{userID} then do the batch delete.
+ Once the design phase is done, going into Alpha or Beta testing, I usually remove any delete-action-queries from the stored queries. Instead I create these in VBA as needed.
Dec 4 '15 #2
Damn, until I read your reply I never even thought of the fact that the code I have currently will just backup the users copy of the FE and not the actual FE. Epic fail. The FE is in fact in a secure location and when I make any changes to it, I just email all users a new copy of the FE. And IT was able to recover a previous version of the DB because it is backed up, but our IT is SLOW and I would rather have the information backed up myself so they don't need to be involved.

Where exactly do you use that code for the BAckEnd? Do you just put that in a module, I'm sorry, I'm still working through this whole VBA thing.

Thanks for the help thus far.
Dec 4 '15 #3
zmbd
5,501 Expert Mod 4TB
I have a command button to close the application and the mainform has an on_close event that cancels the close unless the commandbutton has set a flag indicating that the backup attempt was attempted.
Dec 4 '15 #4

Sign in to post your reply or Sign up for a free account.

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...
3
by: Bernard Dhooghe | last post by:
Suppose a running database (DB2 UDB) with all containers being SMS based (file system as JFS or JFS2 on AIX). How to make a backup (online) by doing a file system backup and not a database...
1
by: sjoshi | last post by:
Hello I'm seeing the backup using SMO fails with big databases (>15GB). I have a 2GB database and I can see the command go thru. in Profiler but after it's about 50-70% done, I get an exception...
7
by: perryche | last post by:
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...
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...
1
by: ttcplkavi | last post by:
hello.. Is anybody know how to do Auto mail sending using postgresql .. Please reply asap
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...
10
VietPP
by: VietPP | last post by:
Hi all, I'm using ComponentOne FlexGrid for VB.NET to display my data. To create a auto scrollbar using a timer object as: Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As...
3
by: busterbaxter | last post by:
Hello, I'm using access 2007 and have one table (Assets). In my table there is a User field (Assets.User) and Deptartment. field (Assets.Department). On my form I have a combo box for User...
0
by: najmi | last post by:
hai.. i want to ask anybody that know how to develop a program in j2me to backup sms or have an example code to be share..
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.