Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

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

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
SteveL13
Asked:
SteveL13
  • 7
  • 6
1 Solution
 
GozrehCommented:
FileCopy "YourCurrentDB.mdb","YourNewFile.mdb"

But you can only do it on other database, not on that is now active
0
 
SteveL13Author Commented:
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
 
GozrehCommented:
   Dim Result As String
   Result = InputBox("Please Enter Name Of New File")
   FileCopy "YourCurrentDB.mdb", Path & "\" & Result & ".mdb"

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
SteveL13Author Commented:
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
 
GozrehCommented:
you need to put in full path
0
 
SteveL13Author Commented:
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
 
GozrehCommented:
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
 
SteveL13Author Commented:
So then is this it?

FileCopy "myfilename.accdb", CurrentProject.Path & "\" & Result & ".accdb"
0
 
GozrehCommented:
FileCopy CurrentProject.Path & "\myfilename.accdb", CurrentProject.Path & "\" & Result & ".accdb"
0
 
SteveL13Author Commented:
Now am getting a permission denied message.
0
 
GozrehCommented:
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
 
GozrehCommented:
was this the solution what you nedded, or you want to copy the actual file you are currently using ?
0
 
SteveL13Author Commented:
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.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now