Am trying to BACKUP database in .bak format and when i compile it am getting
source file doesnt exist error
can anybody please HELP..
Thanks in advance
so what is the database and how are you trying to back it up
Am trying to back up MSaccess database using .bak file.. the that am using is below and it comes right at the place where i ve bolded the words and displays the source file doesnt exist error..
Private Sub BackUpDB()
Dim FSO As New FileSystemObject
Dim sDBfn As String
Dim sDBTmpfn As String
If FSO.FolderExists(App.Path & "/Backup") = False Then
FSO.CreateFolder App.Path & "/Backup"
'set backup file path filename
sDBfn = App.Path & "/Backup/" & Format$(Date, "ddmmyyyy") & ".bak"
'set temporary file
sDBTmpfn = sDBfn & Now - DateValue(Now) & GetTickCount
If FSO.FileExists(sDBTmpfn) = True Then
progStat.Visible = True
lblCBK.Visible = True
Set frmbackup.clsBKU = New clsHuffman
frmbackup.clsBKU.EncodeFile DBPathFileName, sDBTmpfn
If FSO.FileExists(sDBfn) = True Then
FSO.MoveFile sDBTmpfn, sDBfn
Set FSO = Nothing
progStat.Visible = False
lblCBK.Visible = False
isn't sDBTmpfn incorrect, it should be the file name of the database you are trying to back up.
and the MoveFile should probably be a CopyFile
Oh i get it.. thanks a ton..
Chris i tried it aint workin.. Wat i should use in place of sdbtmpfn
the filename of the database you wish to backup, eg
FSO.CopyFile App.Path & "\MyDatabase.mdb", sDBfn
you need to need to ensure that the database is not open at the time. The easiest is to start your VB program in sub Main and backup there before any links to the database have been created.
It worked.. I cant thank u enough chris..