Hello,
I am trying to run a code for copying my database to a different location, but in running the code, I get the following an error, which when "debuged", has this line highlighted in yellow:
oFSO.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True
Any idea what the problem is? Here is the entire code:
Public Function BackupCopy()
'This function will allow you to copy a db that is open,
'You must set a reference to the 'Microsoft Scripting Runtime' for the CopyFile piece to work!
Dim OFSO As FileSystemObject
Dim sSourcePath As String
Dim sSourceFile As String
Dim sBackupPath As String
Dim sBackupFile As String
sSourcePath = "C:\Documents and Settings\tommyf\My Documents\DBackup\"
sSourceFile = "VANPOOL RIDERSHIP 1008.mdb"
sBackupPath = "C:\Documents and Settings\tommyf\My Documents\DBackup\backup\"
sBackupFile = "BackupDB_" & Format(Date, "mmddyyyy") & "_" & Format(Time, "hhmmss") & ".mdb"
Set OFSO = CreateObject("Scripting.FileSystemObject")
OFSO.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True
Set OFSO = Nothing
Beep
MsgBox "Backup was successful and saved @ " & Chr(13) & Chr(13) & sBackupPath & Chr(13) & Chr(13) & "The backup file name is " & Chr(13) & Chr(13) & sBackupFile, vbInformation, "Backup Completed"
End Function
Thanks, in advance, for your help!
Tommy