Copy backend db in run mode. - Re-post

J

James

I have a form that makes a copy of the backend database. The code is below.
However it works fine when I open the database with the shift key, but when
it is open in run mode (not .mde) it gives be an error box that says
"Permission Denied". This is in Access 2000. Anyone know how to fix this
problem.

--------------start code-----------------
Private Sub cmdBackup_Click()
On Error GoTo Err_cmdBackup_Click

FileCopy Me.txtSource, Me.txtDest
MsgBox "Backup Successful.", , "PackageLog 2005"

Exit_cmdBackup_Click:
Exit Sub

Err_cmdBackup_Click:
MsgBox Err.Description
Resume Exit_cmdBackup_Click

End Sub

Private Sub cmdBuildFile_Click()
Dim strFolder As String
strFolder = BrowseFolder("Please select a new folder for the backup file.")
If Not strFolder = vbNullString Then
Me.txtFolderPath = strFolder
End If
End Sub

Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Click

DoCmd.Close

Exit_cmdExit_Click:
Exit Sub

Err_cmdExit_Click:
MsgBox Err.Description
Resume Exit_cmdExit_Click

End Sub

Private Sub Form_Load()
On Error GoTo Err_Form_Load
Dim DataBE, DestinationFile
Dim datenow

datenow = Now()
DataBE = CurrentDBDir & "PLOG2005BE.mdb"
DestinationFile = Me.txtFolderPath & "PLOG2005BE" & Format(datenow,
"mmddyy") & ".bku"

Me.txtSource = DataBE
Me.txtDest = DestinationFile

Exit_Form_Load:
Exit Sub

Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Load

End Sub

Private Sub txtFolderPath_BeforeUpdate(Cancel As Integer)
txtDest.Requery
End Sub
----------------End Code---------------
 
W

Wayne Morgan

FileCopy won't copy open files. I suspect that this form isn't your Startup
form. When you open the database using the shift key, you prevent your
startup form from opening. If you then open this form, the FileCopy works. I
would guess that the startup form is connected to a table in the back-end
file, causing Access to open the back-end file and prevent FileCopy from
working.
 
J

James

Thank you. The switchboard table was on the back-end, so I moved it to the
front and that worked.
 

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

Similar Threads


Top