by Angsuman Banerji (23 Submissions)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 6th November 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
The code gives the full fleged backup / restore utility. The use had to take Drive box,list box, text box, buttons and tab form controls.
API Declarations
'Developed by Angsuman Banerji
Option Explicit
Private Sub Form_Activate()
On Error GoTo ErrHandle
ErrHandle:
If Err.Number = 384 Then Resume Next
Call FormSize(50, 5800, 750, 7850)
Set tempRs = db1.OpenRecordset("SSNwComp", dbOpenSnapshot)
If tempRs.RecordCount > 0 Then
tempRs.MoveFirst
CompList.Clear
AcYearList.Clear
Do Until tempRs.EOF()
CompList.AddItem tempRs.Fields("CompName")
Dim mDate1 As String
Dim mDate2 As String
mDate1 = tempRs.Fields("AcStDate")
mDate2 = tempRs.Fields("AcEnDate")
AcYearList.AddItem mDate1 + " - " + mDate2
tempRs.MoveNext
Loop
End If
End Sub
Private Sub Form_Load()
FormLock = False
SSTab1.Tab = 0
BakDest = BakDir
BakFileName = "Backup1"
TypeList.Clear
TypeList.AddItem "Master"
TypeList.AddItem "Transaction"
GroupList.Clear
GroupList.AddItem "System"
GroupList.AddItem "Accounts"
GroupList.AddItem "Custom"
GroupList.AddItem "Payroll"
End Sub
'Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' ShowStatus "Any button can be executed with Alt & underlined letter on the button."
'End Sub
Private Sub Form_Unload(Cancel As Integer)
FormLock = True
End Sub
'--------------Backup Tab
Private Sub BakDrive_Change()
On Error GoTo ErrHandle
BakDir = BakDrive
ErrHandle:
If Err.Number = 68 Then
MsgBox "Specified Drive Not Abailable"
BakDrive.SetFocus
Exit Sub
End If
End Sub
Private Sub BakDrive_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then BakDir.SetFocus
End Sub
Private Sub BakDir_Change()
BakDest = BakDir
End Sub
Private Sub BakDir_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then BakFileName.SetFocus
End Sub
Private Sub BakFileName_GotFocus()
ShowStatus "Maximum length should not exceed 8."
BakFileName.SelLength = Len(BakFileName)
End Sub
Private Sub BakFileName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then CompresYes.SetFocus
If CharLength(BakFileName, KeyAscii, 8) = False Then KeyAscii = 0
End Sub
Private Sub BakFileName_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
ShowStatus "Enter the file name for the backup file."
End Sub
Private Sub CompresYes_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then CompList.SetFocus
End Sub
Private Sub CompresNo_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then CompList.SetFocus
End Sub
Private Sub CompList_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then TypeList.SetFocus
End Sub
Private Sub TypeList_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then GroupList.SetFocus
End Sub
Private Sub GroupList_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then AcYearList.SetFocus
End Sub
Private Sub AcYearList_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then cmdBakStart.SetFocus
End Sub
Private Sub cmdBakStart_Click()
If CheckFields("BakFileName") = False Then Exit Sub
If CheckFields("CompList") = False Then Exit Sub
If CheckFields("TypeList") = False Then Exit Sub
If CheckFields("GroupList") = False Then Exit Sub
If CheckFields("AcYearList") = False Then Exit Sub
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
'Dim mCompCodeArr() As String
'Dim mTotCompCode As Integer
Dim mType As String
Set tempRs = db1.OpenRecordset("SSNwComp", dbOpenSnapshot)
'mTotCompCode = 0
For i = 0 To CompList.ListCount - 1
If CompList.Selected(i) = True Then
tempRs.FindFirst "CompName= '" + CompList.List(i) + "'"
mCompCode = tempRs.Fields("CompID")
For j = 0 To AcYearList.ListCount - 1
If AcYearList.Selected(j) = True Then
mAcYearNo = AcYearValue(AcYearList.List(j))
For k = 0 To TypeList.ListCount - 1
If TypeList.Selected(k) = True Then
If TypeList.List(k) = "Master" Then mType = "M"
If TypeList.List(k) = "Transaction" Then mType = mType + "T"
End If
Next k
For l = 0 To GroupList.ListCount - 1
If GroupList.Selected(l) = True Then
Call BackupData(mCompCode, mAcYearNo, mType, GroupList.List(l))
End If
Next l
End If
Next j
End If
Next i
'For i = 0 To mTotCompCode - 1
'mTotCompCode = mTotCompCode + 1
'ReDim Preserve mCompCodeArr(mTotCompCode)
'tempRs.FindFirst "CompName= '" + CompList.List(i) + "'"
'mCompCodeArr(i) = tempRs.Fields("CompID")
'MsgBox mCompCodeArr(i)
'Next i
End Sub
Private Sub cmdBakCancel_Click()
Unload Me
End Sub
'--------------Restore Tab
Public Function CheckFields(mObject As String) As Boolean
Dim i As Integer
Dim j As Integer
Select Case mObject
Case "BakFileName"
If Trim(BakFileName) = "" Then
MsgBox "File Name Cannot Be Blank"
BakFileName.SetFocus
Exit Function
End If
Case "CompList"
For i = 0 To CompList.ListCount - 1
If CompList.Selected(i) = True Then j = j + 1
Next i
If j = 0 Then
MsgBox "Atleast One Company Name Should Be Selected"
CheckFields = False
CompList.SetFocus
Exit Function
End If
Case "TypeList"
For i = 0 To TypeList.ListCount - 1
If TypeList.Selected(i) = True Then j = j + 1
Next i
If j = 0 Then
MsgBox "Atleast One Type Should Be Selected"
CheckFields = False
TypeList.SetFocus
Exit Function
End If
Case "GroupList"
For i = 0 To GroupList.ListCount - 1
If GroupList.Selected(i) = True Then j = j + 1
Next i
If j = 0 Then
MsgBox "Atleast One Group Name Should Be Selected"
CheckFields = False
GroupList.SetFocus
Exit Function
End If
Case "AcYearList"
For i = 0 To AcYearList.ListCount - 1
If AcYearList.Selected(i) = True Then j = j + 1
Next i
If j = 0 Then
MsgBox "Atleast One Accounting Year Should Be Selected"
CheckFields = False
AcYearList.SetFocus
Exit Function
End If
End Select
CheckFields = True
End Function
Public Function AcYearValue(pListIndex As Integer) As String
AcYearValue = "01"
End Function
Public Sub BackupData(pCompCode As String, pAcYearNo As String, pType As String, pGroup As String)
'dfsdf
End Sub
No comments have been posted about The code gives the full fleged backup / restore utility. The use had to take Drive box,list box, te. Why not be the first to post a comment about The code gives the full fleged backup / restore utility. The use had to take Drive box,list box, te.