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"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
'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] [3eyes] [3eyes]](/data/assets/smilies/3eyes.gif)
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?"
'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] [3eyes] [3eyes]](/data/assets/smilies/3eyes.gif)