Rick Danger
asked on
access vba run-time error '70' permission
I am getting the error "run-time error '70' permission denied" when performing
FileCopy file1, file2
This is due to the fact that file1, which is an Access database, is open.
Is there a way around this? This code is run overnight and obviously some users are leaving the db running. This is not something I can do much about so need to find a work-around.
Any ideas?
FileCopy file1, file2
This is due to the fact that file1, which is an Access database, is open.
Is there a way around this? This code is run overnight and obviously some users are leaving the db running. This is not something I can do much about so need to find a work-around.
Any ideas?
ASKER
Thanks capricorn1
I think that will only tell me if it failed. I need to find a way to make it work, even if the database is open. I need to somehow find a way of copying a database file that is already open.
I think that will only tell me if it failed. I need to find a way to make it work, even if the database is open. I need to somehow find a way of copying a database file that is already open.
that code is suppose to copy the open database, so, try it first.
of course if there is an error when copying the file, it will tell you that the copy process failed.
of course if there is an error when copying the file, it will tell you that the copy process failed.
ASKER
I don't quite understand where to put and how to run this code. This is part of my code:
Public Sub DoRebuild()
' First off ... copy "R:\Stephen hill time ..." to Local C: Drive
strSource = "R:\Databases\time and Expenses Database.mdb"
FileCopy strSource, "R:\Databases\TimeExpenses Backup.mdb "
FileCopy strSource, "C:\Databases\time and Expenses Database.mdb"
' then - copy the table "InvoiceSummary" - (within the 'un-copied' file)
' (so as to retain Notes and Invoice Preparer data)
' On the fly, get and use the copy as a look-up
' Finally, at the end, delete the copy (so as it can be copied again)
Public Sub DoRebuild()
' First off ... copy "R:\Stephen hill time ..." to Local C: Drive
strSource = "R:\Databases\time and Expenses Database.mdb"
FileCopy strSource, "R:\Databases\TimeExpenses
FileCopy strSource, "C:\Databases\time and Expenses Database.mdb"
' then - copy the table "InvoiceSummary" - (within the 'un-copied' file)
' (so as to retain Notes and Invoice Preparer data)
' On the fly, get and use the copy as a look-up
' Finally, at the end, delete the copy (so as it can be copied again)
Where did you get the code from?
The author of that code should provide you with instructions.
Most Experts here don't like to comment on code that they did not create, because it is not known if the code is even valid for what you need to do.
Beside, there is no way to "Work around" the error or "make it work".
The fact of the matter is that you cannot (easily) copy a database file that is Open and/or In use.
Furthermore if you try to close the DB file that is in use, corruption may result.
You need to make sure the file is closed before trying to access it.
So your first step would be to figure out why the file is being help open.
You can also "BackUp" the DB by creating code that copies all of the Objects to another DB.
(But this will involve more complex code)
Or investigate this group of products:
This will perform almost any basic database maintenance task:
http://www.fmsinc.com/MicrosoftAccess/Scheduler.html
This will monitor who in in the DB and give you options for kicking them out.
http://www.fmsinc.com/MicrosoftAccess/monitor.asp
JeffCoachman
The author of that code should provide you with instructions.
Most Experts here don't like to comment on code that they did not create, because it is not known if the code is even valid for what you need to do.
Beside, there is no way to "Work around" the error or "make it work".
The fact of the matter is that you cannot (easily) copy a database file that is Open and/or In use.
Furthermore if you try to close the DB file that is in use, corruption may result.
You need to make sure the file is closed before trying to access it.
So your first step would be to figure out why the file is being help open.
You can also "BackUp" the DB by creating code that copies all of the Objects to another DB.
(But this will involve more complex code)
Or investigate this group of products:
This will perform almost any basic database maintenance task:
http://www.fmsinc.com/MicrosoftAccess/Scheduler.html
This will monitor who in in the DB and give you options for kicking them out.
http://www.fmsinc.com/MicrosoftAccess/monitor.asp
JeffCoachman
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
pass the path and name of currentdb and new path and db name
could be on the same path/folder but must be different db name, say add a datetime to the backup copy
Open in new window