Results 1 to 6 of 6

Thread: PROGRESSBAR during compact & repair Access database

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,579

    PROGRESSBAR during compact & repair Access database

    possible to show a PROGRESSBAR during compact & repair, via VB 6.0 code?

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,856

    Re: PROGRESSBAR during compact & repair Access database

    What code do you use to compact the Access DB?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,579

    Re: PROGRESSBAR during compact & repair Access database

    Quote Originally Posted by Arnoutdv View Post
    What code do you use to compact the Access DB?
    Code:
    Public Sub COMPACT_DB_OK()
    
     Dim sSource As String
     Dim sDest As String
    
     Me.AZIONI.Caption = "INIZIO COMPATTAZIONE DATABASE T41!"
     DoEvents
    
     Me.LNR.Text = ""
     Me.LDT.Text = ""
    
     sSource = "C:\DATABASE\T41.accdb"
     sDest = "C:\DATABASE\T41_BK.accdb"
    
     Call CompactDB(sSource, sDest)
    
     Me.AZIONI.Caption = "FINE COMPATTAZIONE DATABASE T41!"
     DoEvents
    
     Sleep (500)
    
     End Sub
     Public Function CompactDB(ByVal sSource As String, ByVal sDest As String) As Boolean
    
     Dim iEngineType As Integer
     Dim JRO As JRO.JetEngine
     'Dim CN As ADODB.Connection
    
     On Error GoTo CompactDB_Error
    
     sDest = "C:\DATABASE\T41_BK.accdb"
     sSource = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
     "Data Source=" & sSource
    
     iEngineType = 5
     sDest = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
     "Jet OLEDB:Engine Type=" & iEngineType & _
     ";Data Source=" & sDest
    
     Set JRO = New JRO.JetEngine
     'DoEvents
     Me.Repaint
     DoEvents
     JRO.CompactDatabase sSource, sDest
    
     CompactDB = True
     Set JRO = Nothing
    
     sDest = "C:\DATABASE\T41.accdb"
     If Dir(sDest) <> "" Then
     Kill (sDest)
     End If
    
     Name "C:\DATABASE\T41_BK.accdb" As "C:\DATABASE\T41.accdb"
    
     On Error GoTo 0
    
     Exit Function
    
     CompactDB_Error:
    
     CompactDB = False
     'MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure CompactDB of Module Module1"
    
     On Error Resume Next
    
     'CN.Close
     'Set CN = Nothing
     Set JRO = Nothing
    
     On Error GoTo 0
    
     End Function
     Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    
     If CloseMode = vbFormControlMenu Then
     Cancel = True
     MsgBox "USA IL TASTO ESCI DA QUESTO FORM PER ABBANDONARE!", vbInformation, "T41 - AVVISI"
     End If
    
     End Sub

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,856

    Re: PROGRESSBAR during compact & repair Access database

    No you can't do anything while the CompactDatabase is running.
    The code waits until CompactDatabase has finished and then resumes.

    I can't find anything about JRO having events which you can use.

  5. #5
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,034

    Re: PROGRESSBAR during compact & repair Access database

    Hi Luca,

    just use the Hourglass

    Code:
    Private Sub Command19_Click()
    
      Dim dbSave As String, Msg As String
    
         Me.MousePointer = vbHourglass
         dbSave = CompactMDB(adoConnection)
         Me.MousePointer = vbDefault
         If Len(dbSave) > 0 Then
            Msg = "die Datenbank wurde komprimiert," & vbCrLf & _
                  "der Stand vor Komprimierung ist gesichert in" & _
                  Space(10) & vbCrLf & vbCrLf & dbSave
            MsgBox Msg
         End If
    End Sub
    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  6. #6
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,042

    Re: PROGRESSBAR during compact & repair Access database

    [...]
    Last edited by dz32; Apr 26th, 2019 at 11:28 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width