Option Compare Database
Option Explicit
Dim dblCurRec As Double [COLOR=Green] 'Current record number[/COLOR]
Dim dblPercent As Double [COLOR=Green] 'Unformatted percent of total records processed[/color]
Dim dblPercentProcessed As Double [COLOR=Green] 'Formatted percent of total records processed[/COLOR]
Dim frmProgressBar As Form
Dim PercentCounter As Integer [COLOR=Green]'Number of records within a giving percent
[/COLOR]
Public DisplayIncrement As Integer [COLOR=Green] 'Percentage increment to update the [/COLOR]Progress bar
[COLOR=Green] 'Example -- a value of 10 would show
'10% completed, 20% completed, 30% completed on
'The Progress bar[/COLOR]
Public RecCount As Double
Dim oldpercent As Integer [COLOR=Green] 'The previous percent processed
'Used only if DisplayIncrement is 1
'Open and Setup the Parameters for the Progress bar form[/COLOR]
Public Function ProgressBarOpen(ShowProgBarText As Boolean, _
DisplayIncrement1 As Integer, RecCount1 As Double, _
BarBackColor As Integer, ProgBarColor As Integer, _
ProgBarTextColor As Integer, ProgressBarFormColor As Integer)
On Error GoTo err_ProgressBarOpen
DisplayIncrement = DisplayIncrement1
RecCount = RecCount1
DoCmd.OpenForm "frmProgressBar"
oldpercent = 0
If ProgressBarFormColor = -1 Then
[Forms]![frmProgressBar].Detail.BackColor = 12632256
Else
[Forms]![frmProgressBar].Detail.BackColor = ProgressBarFormColor
End If
[COLOR=Green] 'Show or hide the percentProgresstext[/COLOR]
If ShowProgBarText = False Then
[Forms]![frmProgressBar]![ProgBarText].Visible = False
Else
[Forms]![frmProgressBar]![ProgBarText].Visible = True
End If
If BarBackColor = -1 Then
[Forms]![frmProgressBar]![ProgBar].BackColor = "16473867"
Else
[Forms]![frmProgressBar]![ProgBar].BackColor = BarBackColor
End If
If ProgBarColor = -1 Then
[Forms]![frmProgressBar]![ProgBarText].ForeColor = "0"
Else
[Forms]![frmProgressBar]![ProgBarText].ForeColor = ProgBarColor
End If
If ProgBarTextColor = -1 Then
[Forms]![frmProgressBar]![ProgBarBack].BackColor = "12632256"
Else
[Forms]![frmProgressBar]![ProgBarBack].BackColor = ProgBarTextColor
End If
DoCmd.RepaintObject acForm, "frmProgressBar"
Exit_ProgressBarOpen:
Exit Function
err_ProgressBarOpen:
MsgBox Err.Number & vbCrLf & _
Err.Description & vbCrLf & _
Err.Source, vbCritical, "ERROR"
Resume Exit_ProgressBarOpen:
End Function