CRETE A BACKUP FILE

Answer Posted / haiipl25

Open a project which have one text box name as 'txtbackup' &
one command button name as 'cmdBackup'. After that, put the
following code for Back up the file which is present in that
current folder with the name sample.mdb



Dim obj As Object
Dim path As String
Dim j As Integer
Dim b As String
Dim a(100) As String
Dim i As Integer


If txtbackup <> "" Then
'******************************************
Dim c, c1 As String
i = 0
c = txtbackup.Text
For j = 1 To Len(c)
c1 = Mid(c, j, 1)
If c1 <> "\" Then
a(i) = a(i) & c1
Else
i = i + 1
End If
Next
'*******************************************

Set obj = CreateObject("Scripting.FileSystemObject")
path = txtbackup.Text
b = a(0)

'**** Folder Creation ****

Dim fso As New FileSystemObject
For j = 1 To i
b = b & "\" & a(j)
If Not fso.FolderExists(b) Then
obj.CreateFolder (b)
End If
Next

'**** File Creation ****

If Not fso.FileExists(path & "\sample_" & Format$(Date,
"dd_mm_yy") & ".mdb") Then
obj.CopyFile "" & App.path & "\sample.mdb", "" & path &
"\sample_" & Format$(Date, "dd_mm_yy") & ".mdb"
MsgBox "Data Base Successfuly Back Up in Loction :" & path
& " ", vbInformation, "Back Up"
Else
If MsgBox("Data Base is already exists. Do u want to
replace it?", vbQuestion + vbYesNo, "Confirmation") = vbYes Then
obj.CopyFile "" & App.path & "\sample.mdb", "" & path &
"\sample_" & Format$(Date, "dd_mm_yy") & ".mdb"
MsgBox "Data Base Successfuly Back Up in Loction :" & path
& " ", vbInformation, "Back Up"
End If
End If


Else
MsgBox "Enter the Destination Path.....", vbExclamation

End If

txtbackup.Text = ""
txtbackup.SetFocus
End Sub

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between adodc and adodb in vb?

491


What is understand in resource tracking?

675


How can I speed up my VB database application?

966


What is FireHouse Cursors?

1757


Explain about Caturing Baseline.

628






How do I prevent multiple instances of my program?

977


Difference between Linked Object and Embedded Object?

1791


How do I call a DLL?

1051


What is file in vb?

499


How would you navigate between one document to another document in Internet Explorer ?

1807


what is the Property used to add a menus at runtime?

1643


___ argument can be used to make a menuitem into bold.

1288


Which type of object requires this object?

1581


What is the use of Imagelist Controls ?

1457


What is the use of Tabledef?

1551