Hi all,
I have a progress bar and I want to show users the percentage completion process when executing sql and generating a report. The following code snippet is consists of a function that indicates percentage completion and a procedure that calls the function. However, I'm getting object defined error or application error on this offending line frm.Increfrmnt sPercentage, sStatus.
Any ideas?
Thanks so much for your help.
Option Explicit
Dim frm As Form
Private Sub BellListView_Click()
Dim Index As Integer
Dim Currid As String
Dim PB As Control
Dim sPercentage As Single
Dim sStatus As String
Dim alistitem As ListItem
For Index = 1 To BellListView.ListItems.Count
Set frm = Forms!RCD
Set PB = frm!ProgressBar6
frm.Repaint
PB.Max = BellListView.ListItems.Count
sPercentage = (Index / BellListView.ListItems.Count) * 100
sStatus = "Checking " & Index
frm.Increfrmnt sPercentage, sStatus
sPercentage = (Index / PB.Max) * 100
sStatus = "Checking " & Index
Set alistitem = BellListView.ListItems(Index)
If (alistitem.Selected = True) Then
Currid = BellListView.ListItems(Index).Text
frm.Increment sPercentage, sStatus
MsgBox Currid
Exit For
End If
Next Index
DoCmd.Close acForm, "frmProgress6"
Set PB = Nothing
Set frm = Nothing
End Sub
Private Sub UserForm_Initialize()
frm.Caption = "0% Complete"
End Sub
Public Function Increment(sPercentComplete As Single, _
sDescription As String)
frm.Label10.Caption = sDescription
frm.Repaint
Dim iPercentIncrefrmnt As Integer
iPercentIncrefrmnt = Format(sPercentComplete, "#")
Select Case iPercentIncrefrmnt
Case 10
frm.Frafrm1.Visible = True
frm.Caption = "10% Complete"
frm.Repaint
Case 20
frm.Frafrm2.Visible = True
frm.Caption = "20% Complete"
frm.Repaint
Case 30
frm.Frafrm3.Visible = True
frm.Caption = "30% Complete"
frm.Repaint
Case 40
frm.Frafrm4.Visible = True
frm.Caption = "40% Complete"
frm.Repaint
Case 50
frm.Frafrm5.Visible = True
frm.Caption = "50% Complete"
frm.Repaint
Case 60
frm.Frafrm6.Visible = True
frm.Caption = "60% Complete"
frm.Repaint
Case 70
frm.Frafrm7.Visible = True
frm.Caption = "70% Complete"
frm.Repaint
Case 80
frm.Frafrm8.Visible = True
frm.Caption = "80% Complete"
frm.Repaint
Case 90
frm.Frafrm9.Visible = True
frm.Caption = "90% Complete"
frm.Repaint
Case 100
frm.Frafrm10.Visible = True
frm.Caption = "100% Complete"
frm.Repaint
End Select
End Function
I have a progress bar and I want to show users the percentage completion process when executing sql and generating a report. The following code snippet is consists of a function that indicates percentage completion and a procedure that calls the function. However, I'm getting object defined error or application error on this offending line frm.Increfrmnt sPercentage, sStatus.
Any ideas?
Thanks so much for your help.
Option Explicit
Dim frm As Form
Private Sub BellListView_Click()
Dim Index As Integer
Dim Currid As String
Dim PB As Control
Dim sPercentage As Single
Dim sStatus As String
Dim alistitem As ListItem
For Index = 1 To BellListView.ListItems.Count
Set frm = Forms!RCD
Set PB = frm!ProgressBar6
frm.Repaint
PB.Max = BellListView.ListItems.Count
sPercentage = (Index / BellListView.ListItems.Count) * 100
sStatus = "Checking " & Index
frm.Increfrmnt sPercentage, sStatus
sPercentage = (Index / PB.Max) * 100
sStatus = "Checking " & Index
Set alistitem = BellListView.ListItems(Index)
If (alistitem.Selected = True) Then
Currid = BellListView.ListItems(Index).Text
frm.Increment sPercentage, sStatus
MsgBox Currid
Exit For
End If
Next Index
DoCmd.Close acForm, "frmProgress6"
Set PB = Nothing
Set frm = Nothing
End Sub
Private Sub UserForm_Initialize()
frm.Caption = "0% Complete"
End Sub
Public Function Increment(sPercentComplete As Single, _
sDescription As String)
frm.Label10.Caption = sDescription
frm.Repaint
Dim iPercentIncrefrmnt As Integer
iPercentIncrefrmnt = Format(sPercentComplete, "#")
Select Case iPercentIncrefrmnt
Case 10
frm.Frafrm1.Visible = True
frm.Caption = "10% Complete"
frm.Repaint
Case 20
frm.Frafrm2.Visible = True
frm.Caption = "20% Complete"
frm.Repaint
Case 30
frm.Frafrm3.Visible = True
frm.Caption = "30% Complete"
frm.Repaint
Case 40
frm.Frafrm4.Visible = True
frm.Caption = "40% Complete"
frm.Repaint
Case 50
frm.Frafrm5.Visible = True
frm.Caption = "50% Complete"
frm.Repaint
Case 60
frm.Frafrm6.Visible = True
frm.Caption = "60% Complete"
frm.Repaint
Case 70
frm.Frafrm7.Visible = True
frm.Caption = "70% Complete"
frm.Repaint
Case 80
frm.Frafrm8.Visible = True
frm.Caption = "80% Complete"
frm.Repaint
Case 90
frm.Frafrm9.Visible = True
frm.Caption = "90% Complete"
frm.Repaint
Case 100
frm.Frafrm10.Visible = True
frm.Caption = "100% Complete"
frm.Repaint
End Select
End Function