Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What could be wrong, it worked fine!!

Status
Not open for further replies.

DBSSP

Programmer
Apr 1, 2002
327
US
A little help would be much appreciated on this. Below is my code for a backup automation module. It was working just fine for the past week, but now, all of the sudden,it keeps coming back with an error when it executes this line;

fso.CopyFile strSource, strDest, True

Any ideas on what could be wrong with the code?
**************************************************************
Public Sub BackUp()

On Error GoTo Err_Backup
Dim db As DataBase
Dim strSource As String
Dim strDest As String
Dim strError As String
Dim strDate As String
Dim strDateX As String
Dim fso As FileSystemObject

If MsgBox("Are you sure you want to back up all data?", vbQuestion + _
vbYesNo, "Continue?") = vbYes Then

'Un-comment the following four lines for a new back-up everyday
'strDate = Format(Date, "mm/dd/yy")
'strDateX = Left(strDate, 2) & Mid(strDate, 4, 2)& _
'Right(strDate, 2)
'strDest = " {Drive path}" & strDateX
DoCmd.Hourglass True
Set db = CurrentDb()


'Insert the path of the database you want to backup
strSource = "DatabasePath"



'If you are using a new backup everyday, Un-comment this line and replace the
'database name, and comment out the next line down
'strDest = strDest & "_BackEndDBName.mdb"

'Insert the path and name of the backup file
strDest = "BackupPath"

Set fso = New FileSystemObject
fso.CopyFile strSource, strDest, True

db.Close
Set fso = Nothing

DoCmd.Hourglass False
MsgBox "Backup Complete."
End If

Exit_Backup:
Exit Sub

Err_Backup:
MsgBox "The backup process has failed! Error 120", vbExclamation, "Backup Failed!"

DoCmd.Hourglass False
Resume Exit_Backup

End Sub
**************************************************************

Jay [3eyes]
 
It states permission denied as the error but I have permissions to both paths for everything I want to do. What's up with that? Any ideas?

Jay[3eyes]
 
Nevermind, The database that was possing as a backup was password protected. It's all good now!

Jay [3eyes]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top