I'm using ghudson's backupandzipit function with a few alterations which is working fine. I get a backup file called filename.mdb-Backup_yy_mm_dd which is what I want but the message boxes return mypath\filename.mdb for sBackupPath and -Backup_yy_mm_dd for sBackupFile whereas I want mypath\ for sBackupPath and filename.mdb-Backup_yy_mm_dd for sBackupFile.
Can anyone see what I'm doing wrong?
PHP:
Public Function Backup()
'This function will allow you to copy a db that is open,
'rename the copied db and zip it up to anther folder.
'You must set a reference to the 'Microsoft Scripting Runtime' for the CopyFile piece to work!
'Thanks to Ricky Hicks for the .CopyFile code
Dim fso As FileSystemObject
Dim sSourcePath As String
Dim sSourceFile As String
Dim sBackupPath As String
Dim sBackupFile As String
Dim strFilter As String
Dim strFile As String
strFilter = ahtAddFilterItem(strFilter, "Microsoft Access (*.mdb)", "*.mdb")
strFile = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=False, _
DialogTitle:="Save backup as...", _
Flags:=ahtOFN_HIDEREADONLY)
sSourcePath = Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name)))
sSourceFile = Dir(CurrentDb.Name)
sBackupPath = Left(strFile, Len(strFile) - Len(Dir(strFile)))
sBackupFile = Dir(strFile) & "-Backup" & "_" & Format(Date, "yy_mm_dd") & ".mdb"
Set fso = New FileSystemObject
fso.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True
Set fso = Nothing
MsgBox sBackupPath
MsgBox sBackupFile
End Function
Can anyone see what I'm doing wrong?