-
Oct 19th, 2017, 02:45 AM
#1
Thread Starter
PowerPoster
PROGRESSBAR during compact & repair Access database
possible to show a PROGRESSBAR during compact & repair, via VB 6.0 code?
-
Oct 19th, 2017, 02:50 AM
#2
Re: PROGRESSBAR during compact & repair Access database
What code do you use to compact the Access DB?
-
Oct 19th, 2017, 02:54 AM
#3
Thread Starter
PowerPoster
Re: PROGRESSBAR during compact & repair Access database
Originally Posted by Arnoutdv
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
-
Oct 19th, 2017, 04:49 AM
#4
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.
-
Oct 19th, 2017, 05:02 AM
#5
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.
-
Oct 19th, 2017, 04:33 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|