Show a Progress Bar on Form Loading ... (2 Viewers)

Local time
Today, 09:05
Joined
Feb 28, 2023
Messages
628
Actually, I found another glitch, but I only notice it at home with the slower network connection ...

@Josef P. said in Reply #10 to turn the timer on in the FormCurrent Event, then in the timer event to turn the timer off and load the subforms.

What is happening is every time the form is current, the timer event fires again - so every time I go to a new record, I see a progress bar and my subforms load (actually, the second subform loads too quickly to be visible, but it is being reloaded).

I need the timer to run only on the initial load.

I tried the following, but it didn't seem to change anything:
Code:
Private Sub Form_Current()
    Dim FirstLoad As Integer
    If FirstLoad = 0 Then
        FirstLoad = 1
        Me.TimerInterval = 1
        Unload ufProgress ' Kill progress bar
    Else
        Me.TimerInterval = 0 ' Timer Off
    End If
End Sub

If necessary, I can go back to loading my subforms with the main form and I'll still have the initial progress bar, but I liked the late subform loading idea, if it can be made to work.
 

Josef P.

Well-known member
Local time
Today, 15:05
Joined
Feb 2, 2023
Messages
826
@Josef P. said in Reply #10 to turn the timer on in the FormCurrent Event, then in the timer event to turn the timer off and load the subforms.
It does not have to be Current. It also works in Form.Load if you set the TimerInterval. The timer will still show its effect after Current.
See example in #14.

fix #41
Code:
Private Sub Form_Current()
    ' Dim FirstLoad As Integer ' is 0 for each new procedure execution (Content is removed from memory after exiting the procedure)
    static FirstLoad As Integer ' or use as modul variable
    If FirstLoad = 0 Then
        FirstLoad = 1
        Me.TimerInterval = 1
        Unload ufProgress ' Kill progress bar
    Else
        Me.TimerInterval = 0 ' Timer Off
    End If
End Sub
 
Last edited:
Local time
Today, 09:05
Joined
Feb 28, 2023
Messages
628
Moving the timerInterval to Form_Load solved it - thanks for the quick reply!!!
 
Local time
Today, 09:05
Joined
Feb 28, 2023
Messages
628
@Josef P. - I am seeing an issue now where OCCASIONALLY the two subforms that I delayed loading on fail to load at all and I just see white squares where they should be.

I'm not sure what causes this or how to recreate it. It seems like it happens maybe one time out of 10. Closing the form and re-opening it, it seems to work properly.

I used to see this happen if I had one form open in design view and then opened a different form (with the same subform on both forms), but I got a warning then. Now the subforms just aren't loaded.

I'm considered going back to loading the subforms before the main form, but wanted to see if you had suggestions.
 

Users who are viewing this thread

Top Bottom