954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

source file doesnt exist

Am trying to BACKUP database in .bak format and when i compile it am getting

-2147221504
source file doesnt exist error

can anybody please HELP..

Thanks in advance

Rizvi404
Newbie Poster
11 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

so what is the database and how are you trying to back it up

ChrisPadgham
Posting Pro in Training
413 posts since Sep 2009
Reputation Points: 102
Solved Threads: 78
 

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
DoEvents

'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

Rizvi404
Newbie Poster
11 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

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

ChrisPadgham
Posting Pro in Training
413 posts since Sep 2009
Reputation Points: 102
Solved Threads: 78
 

Oh i get it.. thanks a ton..

Rizvi404
Newbie Poster
11 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Chris i tried it aint workin.. Wat i should use in place of sdbtmpfn

Rizvi404
Newbie Poster
11 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

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.

ChrisPadgham
Posting Pro in Training
413 posts since Sep 2009
Reputation Points: 102
Solved Threads: 78
 

It worked.. I cant thank u enough chris..

Rizvi404
Newbie Poster
11 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You