FileCopy for backup

D

Doug F.

I want the user to click a button to backup the database they are in.
Using:
strProduction = CurrentDb.Name
FileCopy strProduction, "c:\mydir\test.mdb"
I get: Permission denied

Also, as I peruse other posts it seems that FileCopy is suggested
even though there is some risk. That risk being as I copy strProduction
which of course is open, test.mdb (written to) may be corrupt if an error
occurs.
And my strProduction although open is safe?
Am I correct in this and if so then does one just take the risk?
Can I check for errors?
Thanks,
Doug
 
T

Tom Wickerath

Hi Doug,

Try the method that the Access Junkie, and MVP Alumni, Jeff Conrad describes
in this article. Note: You do not need to implement Access User Level
Security (ULS) to use the customized login screen for other purposes:

Creating A Customized Login Screen For A Secured Database
http://www.access.qbuilt.com/html/custom_login.html

Scroll down a bit in the article, where you should see this sub title:
A Custom Login Form Can Provide Multiple Solutions

and refer to the second paragraph in this section.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
D

Doug F.

Thanks Tom.
I bet that I can launch an Access database and
pass the Database Password only. Looking now.
Doug
 
T

Tom Wickerath

Hi Doug,

Perhaps this will help...

Option Compare Database
Option Explicit

' HOW TO: Open a Password-Protected Database Through Automation
' in Access 2000 http://support.microsoft.com/?id=235422

Sub OpenPasswordProtectedDB()
' The original version with a change to the strDbName only. Note: Password
is case sensitive.

'Define as Static so the instance of Access doesn't close when the
procedure ends.
Dim acc As Access.Application
'Static acc As Access.Application

Dim db As DAO.Database
Dim strDbName As String
strDbName = "C:\Codescratch\db1_2002.mdb"
Set acc = New Access.Application
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=nero")
acc.OpenCurrentDatabase strDbName

db.Close
Set db = Nothing
End Sub

Sub OpenPasswordProtectedDB2(strPassword As String)
' A modified version of the original code in KB 235422, which allows
' one to specify the password at run-time. Note: Password is case sensitive.

' From Immediate Window:
' OpenPasswordProtectedDB2 "YourPassword"

'Define as Static so the instance of Access
'doesn't close when the procedure ends.
Static acc As Access.Application
Dim db As DAO.Database
Dim strDbName As String

strDbName = "C:\Codescratch\Test.mdb"
strPassword = ";PWD=" & strPassword & ""

Set acc = New Access.Application
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, strPassword)
acc.OpenCurrentDatabase strDbName
db.Close
Set db = Nothing
End Sub


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
D

Doug F.

Again, thank you.
D.

Tom Wickerath said:
Hi Doug,

Perhaps this will help...

Option Compare Database
Option Explicit

' HOW TO: Open a Password-Protected Database Through Automation
' in Access 2000 http://support.microsoft.com/?id=235422

Sub OpenPasswordProtectedDB()
' The original version with a change to the strDbName only. Note: Password
is case sensitive.

'Define as Static so the instance of Access doesn't close when the
procedure ends.
Dim acc As Access.Application
'Static acc As Access.Application

Dim db As DAO.Database
Dim strDbName As String
strDbName = "C:\Codescratch\db1_2002.mdb"
Set acc = New Access.Application
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=nero")
acc.OpenCurrentDatabase strDbName

db.Close
Set db = Nothing
End Sub

Sub OpenPasswordProtectedDB2(strPassword As String)
' A modified version of the original code in KB 235422, which allows
' one to specify the password at run-time. Note: Password is case sensitive.

' From Immediate Window:
' OpenPasswordProtectedDB2 "YourPassword"

'Define as Static so the instance of Access
'doesn't close when the procedure ends.
Static acc As Access.Application
Dim db As DAO.Database
Dim strDbName As String

strDbName = "C:\Codescratch\Test.mdb"
strPassword = ";PWD=" & strPassword & ""

Set acc = New Access.Application
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, strPassword)
acc.OpenCurrentDatabase strDbName
db.Close
Set db = Nothing
End Sub


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top