patriciaxxx
Programmer
Here is my mod the highlighted line creates a backup of the db which can take a second to several minutes depending on its size.
For this line I need to open a form which acts as the progress meter to show the actual progress of the backup action.
Here is the form code for the progress meter.
Can anyone show me how to combine the two codes to achieve what I want.
Code:
[COLOR=#204A87]Public Function BackupDatabase()
Dim strData As String
Dim strDir As String
Dim lngOpen As Long
Dim datBackup As Date
Dim strBkp As String
Dim strDbBkp As String
Dim intBkp As Integer
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblBackupDatabase", dbOpenDynaset)
rst.MoveFirst
lngOpen = rst!OpenCount
datBackup = rst!LastBackup
rst.Close
Set rst = Nothing
strData = Mid(db.TableDefs("tblBackupDatabase").Connect, 11)
strDbBkp = CreateObject("scripting.filesystemobject").GetBaseName(strData)
strDir = Left(strData, InStrRev(strData, "\"))
strBkp = Dir(strDir & "BackupData\" & strDbBkp & "*.mdb")
strBkp = strDir & "BackupData\" & strDbBkp & "_Bkp" & Format(Date, "yymmdd") & ".mdb"
[highlight #FCE94F]DBEngine.CompactDatabase strData, strBkp[/highlight]
MsgBox "Backup created successfully.", vbInformation, "Backup Database"
Set db = Nothing
End Function[/color]
For this line I need to open a form which acts as the progress meter to show the actual progress of the backup action.
Here is the form code for the progress meter.
Can anyone show me how to combine the two codes to achieve what I want.
Code:
[COLOR=#204A87]Private Sub cmdGo_Click()
Dim inti As Integer
Dim dblPct As Double
Me.lblEscape.Visible = True
Me.lblAbort.Visible = False
Me.txtI.Visible = True
Me.txtPctComplete.Visible = True
Me.boxWhole.Visible = True
Me.boxPct.Visible = True
Do Until inti > Me.txtNumIterations
dblPct = inti / Me.txtNumIterations
Me.txtPctComplete = dblPct
Me.boxPct.Width = Me.boxWhole.Width * dblPct
Me.txtI = inti
'If Me.txtI Mod 1 = 0 Then
DoEvents
'End If
inti = inti + 1
Loop
Me.lblEscape.Visible = False
End Sub
[/color]