Solved

How create a copy of the current database and give it a name

Posted on 2014-01-30
13
222 Views
Last Modified: 2014-01-30
From a command button of a form I want to create a backup copy of the current database and be able to give it a name.

How can this be done?

--Steve
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 10

Expert Comment

by:Gozreh
ID: 39820969
FileCopy "YourCurrentDB.mdb","YourNewFile.mdb"

But you can only do it on other database, not on that is now active
0
 

Author Comment

by:SteveL13
ID: 39820982
But won't that give the new file a static name of YourNewFile.mdb ?

I want them to be able to name it as it is being copied.
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 39820994
   Dim Result As String
   Result = InputBox("Please Enter Name Of New File")
   FileCopy "YourCurrentDB.mdb", Path & "\" & Result & ".mdb"

Open in new window

0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:SteveL13
ID: 39821310
Am getting an error.  Says it can't find the file.

Here is what I have...

   FileCopy "myfilename.accdb", Path & "\" & Result & ".accdb"

Note the accdb extension.
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 39821330
you need to put in full path
0
 

Author Comment

by:SteveL13
ID: 39821342
What would the code be for a user that may have it in their own Document folder?

I don't want it to be a static address but use the current user's Documents folder.
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 39821357
If the file that you want to copy is in same location that you current application you can use CurrentProject.Path

If you want to use the user My Documents, you can use = Environ$("USERPROFILE") & "\My Documents\"
0
 

Author Comment

by:SteveL13
ID: 39821369
So then is this it?

FileCopy "myfilename.accdb", CurrentProject.Path & "\" & Result & ".accdb"
0
 
LVL 10

Accepted Solution

by:
Gozreh earned 500 total points
ID: 39821372
FileCopy CurrentProject.Path & "\myfilename.accdb", CurrentProject.Path & "\" & Result & ".accdb"
0
 

Author Comment

by:SteveL13
ID: 39821391
Now am getting a permission denied message.
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 39821400
I wrote before
But you can only do it on other database, not on that is now active
it will only work if you want to copy the backend database, or another database
you canot copy file that is currently open
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 39821658
was this the solution what you nedded, or you want to copy the actual file you are currently using ?
0
 

Author Comment

by:SteveL13
ID: 39821690
This solution is working fine.  Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
run FileCopy code from a string 6 50
Access vs Access runtime 6 57
ListData refresh onClick 5 40
Outlook 2016 VB code syntax 4 25
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

736 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question