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

Recommended Answers

All 7 Replies

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"
End If

'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
FSO.DeleteFile sDBTmpfn
End If

'show ctl
progStat.Visible = True
lblCBK.Visible = True

'start backup
Set frmbackup.clsBKU = New clsHuffman
frmbackup.clsBKU.EncodeFile DBPathFileName, sDBTmpfn

'rename file
If FSO.FileExists(sDBfn) = True Then
FSO.DeleteFile sDBfn
End If
FSO.MoveFile sDBTmpfn, sDBfn

Set FSO = Nothing
progStat.Visible = False
lblCBK.Visible = False
End Sub

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..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.