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 - Sub backup()
-
Dim dTime As Date
-
On Error Resume Next
-
dTime = InputBox("Create a backup at", , Time + TimeValue("00:00:05"))
-
If Err.Number <> 0 Then Exit Sub
-
Do Until Time = dTime
-
DoEvents
-
Loop
-
Dim sfile As String, oDB As DAO.Database
-
'IF DAO.dll does not load, then find
-
'ACEDAO.dll in Program Files (64-bit machine) or MS Office AC DB Engine Object
-
sfile = CurrentProject.Path & "\" & "Staff Data" & ".accdb"
-
If Dir(sfile) <> "" Then Kill sfile
-
Set oDB = DBEngine.Workspaces(0).CreateDatabase(sfile, dbLangGeneral)
-
oDB.Close
-
DoCmd.Hourglass True
-
-
Dim oTD As TableDef
-
For Each oTD In CurrentDb.TableDefs
-
If Left(oTD.NAME, 4) <> "MSys" Then
-
DoCmd.CopyObject sfile, , acTable, oTD.NAME
-
'OR: DoCmd.TransferDatabase acExport,"Microsoft Access", sFile, acTable,oTD
-
End If
-
Next oTD
-
-
DoCmd.Hourglass False
-
MsgBox "Backup is stored in the same folder"
-
End Sub
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. - Select Case oTD.NAME
-
case “operational areas”
-
DoCmd.CopyObject sfile, , acTable, oTD.NAME
-
case “Projects”.
-
DoCmd.CopyObject sfile, , acTable, oTD.NAME
-
case “Communities”
-
DoCmd.CopyObject sfile, , acTable, oTD.NAME
-
case “Zones”
-
DoCmd.CopyObject sfile, , acTable, oTD.NAME
-
-
End Select
-
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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....
|
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...
|
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
| |
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...
|
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
|
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....
|
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...
|
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,...
|
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,...
| |
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...
|
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...
|
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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |