Access cannot find form or objects within form

paul8304424

New member
Local time
Today, 08:12
Joined
Mar 21, 2012
Messages
5
Hi Guys,
Getting frustrated now :(
I've set up a progress bar activex oject within a form called frmProgressBar. The Progress bar object is called ProgressBar0 and there are two labels (Label1 and Label2) along with a button called cmdClose.

As part of another routine, I am calling the following subroutine as setProgressBar("frmProgressBar","Next step",1)
After lots of messing about frmProgressBar opens but then the code halts at
Set prg = !ProgressBar0.Object
stating "object required"

Any advice would be greatfully appreciated.

Cheers,
Paul

Code:
Sub setProgressBar(frmPB As String, strCurrStep As String, intvalue As Long)
'frmPB is Progress bar form to allow for flexibility, strCurrStep is notification of progress step, intvalue is measure of completeness
Dim prg As ProgressBar
Dim strcomplete As String
Dim fmin As String
Dim fmax As String
'Check if progress bar form is open. Open form if not, activate is is open
If CurrentProject.AllForms(frmPB).IsLoaded = False Then
        DoCmd.OpenForm frmPB
End If
DoCmd.SelectObject acForm, frmPB
'Min and Max for indicator
fmin = 1
fmax = 100
With ActiveForm
Set prg = !ProgressBar0.Object
    prg.Value = intvalue
    strcomplete = Format((prg.Value / prg.Max) * 100, "##") & " % Complete"
    .Label1.Caption = strcomplete
    .Label2.Caption = strCurrStep
    DoCmd.RepaintObject
End With
If intvalue = 100 Then
    ActiveForm.cmdClose.Visible = True
Else
    ActiveForm.cmdClose.Visible = False
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom