Solved

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

Posted on 2014-01-30
13
217 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
  • 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
 

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now