On Error Resume Next
Err.Clear
Dim strSourcePath As String, strSourceName As String, strCopyPath As String, strCopyName As String
strSourcePath = "C:"
strSourceName = Nz(Me.Combo16,"")
strCopyPath = "D:"
strCopyName = Replace(strSourceName, ".accdb","") & "_" & Format(Now(),"yyyy-MM-dd") & ".accdb"
If Right(strSourcePath, 1) <> "\" Then strSourcePath = strSourcePath & "\"
If Right(strCopyPath, 1) <> "\" Then strCopyPath = strCopyPath & "\"
If Err Then
MsgBox "Error encountered trying to copy database", vbCritical
Else
Dim fso As New FileSystemObject
With fso
If .FolderExists(strSourcePath) Then
If .FolderExists(strCopyPath) Then
If .FileExists(strSourcePath & strSourceName) Then
If Not .FileExists(strCopyPath & strCopyName) Then
.CopyFile strSourcePath & strSourceName, strCopyPath & strCopyName
If Err Then
MsgBox "Error encountered trying to copy database", vbCritical
Else
MsgBox "Database copied successfully", vbInformation
End If
Else
MsgBox "Could not copy database: destination file exists", vbCritical
End If
Else
MsgBox "Could not copy database: destination path does not exist", vbCritical
End If
Else
MsgBox "Could not copy database: Source file does not exist", vbCritical
End If
Else
MsgBox "Could not copy database: Source path does not exist", vbCritical
End If
End With
End If