473,480 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

backup tables

7 New Member
I have this code that backs up all my tables in the same folder.

I want to however back up only specified table with names; “operational areas”, “Communities”, “Zones” and “Projects”.

Can I please get help on how to integrate that into my existing code or any other way to achieve that


Expand|Select|Wrap|Line Numbers
  1. Sub backup()
  2.    Dim dTime As Date
  3.     On Error Resume Next
  4.     dTime = InputBox("Create a backup at", , Time + TimeValue("00:00:05"))
  5.     If Err.Number <> 0 Then Exit Sub
  6.     Do Until Time = dTime
  7.         DoEvents
  8.     Loop
  9.     Dim sfile As String, oDB As DAO.Database
  10.     'IF DAO.dll does not load, then find
  11.     'ACEDAO.dll in Program Files (64-bit machine) or MS Office AC DB Engine Object
  12.     sfile = CurrentProject.Path & "\" & "Staff Data" & ".accdb"
  13.     If Dir(sfile) <> "" Then Kill sfile
  14.     Set oDB = DBEngine.Workspaces(0).CreateDatabase(sfile, dbLangGeneral)
  15.     oDB.Close
  16.     DoCmd.Hourglass True
  17.  
  18.     Dim oTD As TableDef
  19.     For Each oTD In CurrentDb.TableDefs
  20.         If Left(oTD.NAME, 4) <> "MSys" Then
  21.             DoCmd.CopyObject sfile, , acTable, oTD.NAME
  22.             'OR: DoCmd.TransferDatabase acExport,"Microsoft Access", sFile, acTable,oTD
  23.         End If
  24.     Next oTD
  25.  
  26.     DoCmd.Hourglass False
  27.     MsgBox "Backup is stored in the same folder"
  28. End Sub
Apr 6 '14 #1
1 2150
jimatqsi
1,271 Recognized Expert Top Contributor
coachafrane,
Here's one way. Put this code in place of your "if left" block of code.

Expand|Select|Wrap|Line Numbers
  1. Select Case oTD.NAME
  2. case “operational areas”
  3.      DoCmd.CopyObject sfile, , acTable, oTD.NAME
  4. case “Projects”.
  5.      DoCmd.CopyObject sfile, , acTable, oTD.NAME
  6. case “Communities”
  7.      DoCmd.CopyObject sfile, , acTable, oTD.NAME
  8. case “Zones”
  9.      DoCmd.CopyObject sfile, , acTable, oTD.NAME
  10.  
  11. End Select
  12.  
And please remember to use Code tags around any program code you post. It's simple, just click the [CODE/] button and type your code between the tags that appear.

Jim
Apr 6 '14 #2

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

Similar topics

1
2141
by: Rajesh Kapur | last post by:
I have about 20 databases in a single MySQL instance running 4.0.21 on RHEL3. I have a healthy mix of MyISAM and InnoDB tables. Howerver these two types do not mix within a single database. A...
5
10532
by: David | last post by:
I am a little confused by DB2 Backup and Export. I used "db2 backup db QAS to /dev/rmt0" backuping 650GB database to a IBM LTO 3581 (1 drive) only 11 hours. But I used "db2 export to /dev/rmt0...
16
3941
by: john | last post by:
How safe is it to back up a single user mdb when it is opened. No tables are opened at the time of the backup. The only object that is open is the form from which the backup code is being run....
2
2965
by: rdemyan via AccessMonster.com | last post by:
For some of my really important tables, I have backup tables in the backend file. The idea is that if a user accidentally screws up data, they can go to a form and restore from the backup table...
3
1927
by: Michael | last post by:
Happy new year. I am looking for code that will go through all tables in MYSQL db and transfer records into text or excel files. Thanks
6
27929
by: javelin | last post by:
I'm having difficulty searching for an answer to this challenge. Can someone give me a clue on the right keywords to use to find a discussion on this subject? All of the ones I saw appear to touch...
7
3758
by: peashoe | last post by:
I need to be able to add a button on my site that will backup an SQL table (not the whole database) - does anyone know how to do that? Thanks in advance Lisa
5
6537
by: Troels Arvin | last post by:
Hello, Every so often, I'm asked to help people recover data from tables that were either dropped or where to much data was DELETEed. The complications related to restoring data are a problem....
3
3153
by: Robertf987 | last post by:
Well, I think I've described what I want to do in the title here. In the database, I have two main tables that contain the main data for the database. One for group expenditures, another for...
0
7041
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
7044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7084
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6739
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
6929
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...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
181
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.