Loading... or Waiting... Pop-up

modest

Registered User.
Local time
Today, 17:42
Joined
Jan 4, 2005
Messages
1,220
I would like a dialog, form, or whatever is easiest to post an animated pop up when a query is loading.

The thing is, I have a series of queries that runs to create a report. The users don't know to look at the mouse (they're ignorant). So while the queries are running, I'd like to display "Processing..", or "Loading..", or something to that extent.

Is there a better way then opening a form that says it, run the queries, and then close the form when queries are finished?
 
I do a simular thing on the form from which the reports are called. Using the TimerInterval and the Form_Timer() to animate the what you like.

Also in the modules that run the calculations are reports, it required DoEvents to allow the Form_Timer event to run.

I’m sure the same thing could be done on a pop-up.
Would that work?
 
Thank you for replying ;)

So how should I go about doing this? Let's say the pop-up form has rectangles that change back and forth from transparent to a solid color

(example)The periods are the rectangles and the form looks like each line every 2 seconds:
Loading
Loading.
Loading..
Loading...

I'm not too familiar with form_timer() so in this "pop-up" form do I turn the transparencies on and off?

Additionally, was I right about opening the form before the queries are run... and then placing the close command after the queries.-- I ask this because if the last query takes, let's say, 5 minutes to run. Will the close command happen while the query is searching for the data... or will it occur after it's done searching the data.

I guess I just need to know if there's a way to determine whether the query is still running or not. More importantly, when does the VBA interpreter read the next line of code?
 
Code:
Private Sub Form_Load()
    Me.TimerInterval = 2000
End Sub

Private Sub Form_Timer()
    If Me.boxFlash.BackStyle = 0 Then
        Me.boxFlash.BackStyle = 1
    Else
        Me.boxFlash.BackStyle = 0
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Me.TimerInterval = 0
End Sub

If you place this in the pop-up form, If the form is in dialog mode you might have to place a DoEvents in Form_Timer() but Im not to sure.

VB runs each line of code one at a time, you can test this by running in debug mode and stepping through. To see if it closes at the right time.
 
I realize I can't do it in dialog mode because the queries wouldn't be called... unless i run the queries from the popup (which I dont want to do)

... I'll give this a shot though, thank you
 
I've put this in a temporary database and changed the timerinterval to 500 (half a second).

I can already tell that this isn't going to work when I run a query. Apparently Access is not a multi-tasking application =) In this prototype db, the queries don't run for that long (about 2 seconds), but my pop-up "Loading" form does not open correctly (only half of it is painted to the screen).

I've tried using "docmd.openform" and the "docmd.close acform" functions... as well as having the popup form loaded when my main form is loaded and just making it visible/invisible (the problem with this is that the timer runs in the background and steals resources)...but still this doesn't work

I really wished to have the animation, but if I can't I guess I'll have to have a static dialog :(
 
A little help... I'm not using the macro because my queries are conditional.. so in VBA, I basically had everything the article said. What I didn't do was a repaint (which takes care of the load).

This still does not help the issue I have with my animations. Here's the code I'm using.
Code:
[COLOR=Blue]Private Sub Form_Load()[/COLOR]
    Me.TimerInterval = 500
    
    Me.Period1.Visible = False
    Me.Period2.Visible = False
    Me.Period3.Visible = False
[COLOR=Blue]End Sub[/COLOR]

[COLOR=Blue]Private Sub Form_Timer()[/COLOR]
    If Me.Period3.Visible = True Then
        Me.Period1.Visible = False
        Me.Period2.Visible = False
        Me.Period3.Visible = False
        
        ElseIf Me.Period2.Visible = True Then
            Me.Period3.Visible = True
            
        ElseIf Me.Period1.Visible = True Then
            Me.Period2.Visible = True
            
        Else
            Me.Period1.Visible = True
    End If
  
[COLOR=Green]  'Ive tried each of the following separately and in combination  [/COLOR] 
    DoCmd.RepaintObject acForm, "Loading"
[COLOR=Green]    'Me.Repaint
    'Me.Refresh[/COLOR]
    
[COLOR=Blue]End Sub[/COLOR]

[COLOR=Blue]Private Sub Form_Unload(Cancel As Integer)[/COLOR]
    Me.TimerInterval = 0
[COLOR=Blue]End Sub [/COLOR]
 
I like to use a custom message in the forms status bar.

Code:
    Dim RetVal As Variant

    Application.SetOption "Show Status Bar", True

    RetVal = SysCmd(acSysCmdSetStatus, "Select the drive or directory you wish to search")
    
    MsgBox "Testing...Look at the status bar text!"

    RetVal = SysCmd(acSysCmdClearStatus)

If you really want to display differnet labels during a process then you need to "pause" your code to allow the label to appear. The Sleep API will not do that. Search this forum for the keyword PAUSE and my user name GHUDSON and you will find my Pause() function that do what you want. You just have to insert a Pause(1) in between each code line where you want a lable to be visible.
 
The problem with pausing or sleeping... is that I want to be able to run code behind it. I want something similar to an animated gif.. but without having to create one =)
 
have you placed the code
DoEvents

where all the work is been done, this will stop whats its doing there, do the timer event which is waiting and then it will return to what it was doing.

If the code is not in a loop, you will need to place DoEvents through out your code I do belive.

Just done one this morning and its working, :)
 
If the only way to do this is by putting "artificial" code between my meaningful code... then I guess this can't be done. Doing that would just be a waste of time, and would make my code messy.

More importantly, that would cause the animation to be event triggered and not time triggered. If need be, I could possibly open a window using APIs and do this :confused: but I'll hold off until that's my last option.

My main form runs a series of conditional (if) statements ... and queries based off of that. It searches a large database, so the dots would not be painted uniformly because of the varied query length.

Thank you for your helps everyone, but I guess I'm not going to be able to animate :(

-modest
 
Access has a problem with trying to do two things at once.

The status bar text message is a great way to give the users an update as to what is happening. Change the message at the beginning of each step of the function. I also can help you as you try to debug or test a series of queries [functions, etc] for you can give an on screen update without having to use message boxes which would stop your code until the OK button was clicked.

Try it.
 
I'll look into it :) But the status bar is a no go. I mean it says it's running a query and that's enough. Users just don't see that... they need something in front of them that won't go away. A form.. an animated form :)
 
You could change the caption of a label of have a special label made visible when needed that could give the users an onscreen notice as to what is or will be happening. You can customize the label to appear where ever and format it to suit your needs. You will need to use my pause function to give the label the time it needs to be visible and then let your queries run. You could then change the label or make it visible, the Pause(1), the run the next query if you need to alert the users as to what step is taking place.

Code:
Me.label1.Visible = True
Me.label1.Caption = "Step 1"
Pause(1)
RunQuery1

Me.label1.Caption = "Step 2"
Pause(1)
RunQuery2
 
Here's how I did it.



I built a forms application in VB.NET with some picture boxes with images and a timer control used to animate the images. The code is set up for an 8 frame animation but you can alter the code to match however many frames you need. Just make sure you reset the TimeInt to zero at the last frame to loop the animation.

You can download the project from github here...

"https://github.com/jSullivan11/VBLoadAnimation.git"



Or if you feel like building your own...



Public Class Form1
Dim TimeInt As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TimeInt = 0
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

TimeInt = TimeInt + 1

If TimeInt = 1 Then
img1.Visible = True
img2.Visible = False
img3.Visible = False
img4.Visible = False
img5.Visible = False
img6.Visible = False
img7.Visible = False
img8.Visible = False
End If

If TimeInt = 2 Then
img1.Visible = False
img2.Visible = True
img3.Visible = False
img4.Visible = False
img5.Visible = False
img6.Visible = False
img7.Visible = False
img8.Visible = False
End If

If TimeInt = 3 Then
img1.Visible = False
img2.Visible = False
img3.Visible = True
img4.Visible = False
img5.Visible = False
img6.Visible = False
img7.Visible = False
img8.Visible = False
End If

If TimeInt = 4 Then
img1.Visible = False
img2.Visible = False
img3.Visible = False
img4.Visible = True
img5.Visible = False
img6.Visible = False
img7.Visible = False
img8.Visible = False
End If

If TimeInt = 5 Then
img1.Visible = False
img2.Visible = False
img3.Visible = False
img4.Visible = False
img5.Visible = True
img6.Visible = False
img7.Visible = False
img8.Visible = False
End If

If TimeInt = 6 Then
img1.Visible = False
img2.Visible = False
img3.Visible = False
img4.Visible = False
img5.Visible = False
img6.Visible = True
img7.Visible = False
img8.Visible = False
End If

If TimeInt = 7 Then
img1.Visible = False
img2.Visible = False
img3.Visible = False
img4.Visible = False
img5.Visible = False
img6.Visible = False
img7.Visible = True
img8.Visible = False
End If

If TimeInt = 8 Then
img1.Visible = False
img2.Visible = False
img3.Visible = False
img4.Visible = False
img5.Visible = False
img6.Visible = False
img7.Visible = False
img8.Visible = True
TimeInt = 0
End If
End Sub

End Class



In access I created a module to open and close the VB.NET application. I named the module LoadAnim. I named the VB.NET application LoadAnimation.exe, make sure you place this application in the same folder as your access database.



Module code...



Option Compare Database

Public vPID As Variant

Public Sub Go()

vPID = Shell(CurrentProject.path & "\LoadAnimation.exe", vbNormalFocus)

End Sub

Public Sub NoGo()

Call Shell("TaskKill /F /PID " & CStr(vPID), vbHide)

End Sub



In your VBA code place the command "LoadAnim.Go" before the queries run and "LoadAnim.NoGo" after the queries run.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom