Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-01-30
13
Medium Priority
?
226 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

650 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