Hello everyone. I am making a form to backup my Ms-Access database in vb 6.0. I have a textbox (txtdestination) a progress bar (progstat) a command button (cmdbackup) and a few labels to show different info. I have the following code in my backup form :

Dim mintCount As Integer, mintPause As Integer
Dim dbasize As Long
Dim PathName As String
Private Sub cmdbackup_Click()
If txtDestination <> "" Then
    FileCopy PathName, txtDestination
    lblCount.Visible = True
    lblInform.Visible = True
'    lblCBK.Visible = True
    progStat.Visible = True
    progStat.Value = progStat.Value + 2
    CountMe
    'If the Progress Bar (ProgLoad) is 100% then your function happens.
If progStat.Value = 100 Then
    MsgBox "Backup database complete", vbInformation
    Unload Me
Else
    If txtDestination = "" Then
     progStat.Value = 0

       'Your function, can be anything. Open another form, frmMain.show... Ect.
    End If
    End If
    End If
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub Form_Activate()
lblSize = Format((dbasize / 1024) / 1024, "standard") & "MB."
End Sub
Private Sub cmdDestination_Click()
Me.commdg.Filter = "*.mdb"
Me.commdg.ShowSave
Dim strTemp As String
    strTemp = Me.commdg.FileName & ".mdb"
    If strTemp <> "" Then
    txtDestination = strTemp
    End If
End Sub
Private Sub Form_Load()
PathName = App.Path & "\main.mdb"
dbasize = FileLen(PathName)
End Sub
Private Sub CountMe()
   mintPause = mintPause + 1
   If mintCount < 0 Then
        mintCount = mintCount + 1
        lblCount.Caption = "(" & mintCount & "%)..."
 '        frmSplash.Refresh

    ElseIf mintCount < 100 Then
        mintCount = mintCount + 2
        lblCount.Caption = "(" & mintCount & "%)..."
'        frmSplash.Refresh

    End If

    If mintPause = 100 Then
        lblCount.Caption = "App..."
        lblInform.Caption = "Starting"
    ElseIf mintPause > 180 Then

        Unload Me

   End If
End Sub

The problem is when I clicked cmbbackup the backup is created as per txtdestination and the progressbar stands in 2%, its not completing 100%, I don't have any clued. Why this is not completing to 100% ? Any help plz.

Private Sub CountMe(prg As ProgressBar)
   mintPause = mintPause + 1
   If mintCount < 0 Then
        mintCount = mintCount + 1
        prg.Value = mintCount
        lblCount.Caption = "(" & mintCount & "%)..."
 '        frmSplash.Refresh
    ElseIf mintCount < 100 Then
        mintCount = mintCount + 2
        prg.Value = mintCount
        lblCount.Caption = "(" & mintCount & "%)..."
'        frmSplash.Refresh
    End If
    If mintPause = 100 Then
        lblCount.Caption = "App..."
        lblInform.Caption = "Starting"
        prg.Value = 0
    ElseIf mintPause > 180 Then
        Unload Me
   End If
End Sub

Now, when the call is made...

progStat.Visible = True
    ''progStat.Value = progStat.Value + 2 - Remove this...
    CountMe (progStat)

i am having "Error : Type Mismatch " in the line

CountMe (progStat)

You may be interested in this also.

Thanks you debasisdas for replying. I have tried the code but it gives me an error in the line

DBTempSource As Database

"User defined type not defined"
Is it possible to help me on my existing code rather then to put a new one. Anyway thank.

Can you check this things?

  1. What is the max of your progress bar, is it 100?

  2. Interval of your timer control? though this won't cause the problem if > 0

Here's what i did for my backup module before:

  1. Same as you did, i have a timer and a progress bar. But I used FileSystemObject for it.

  2. Codes for my backup is on a sub-module

  3. And the progressbar increment process is on my timer control

  4. On the Backup Button, when it is clicked, the timer control will be enabled.

Note:

Make sure that the timer is disabled on form load/activate event.
The attachment is only from my Thesis Project so, it's only for a reference, you'll get it.

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.