?
Solved

while waiting for form to load display progress bar

Posted on 2004-09-08
4
Medium Priority
?
294 Views
Last Modified: 2008-02-01
i have a for next loop reading about 29 records this takes a bit when i have the form load


events are as fallows

1: form loads alowing user to pick from pulldown
1a: on this same form we have a menu with report/show report
1b: if the user clicks the show report this loads onther form(heres where my problem lies)

2: report form loads with loop 0 to 28
2a: i assume i have to place the progress bar advancement here as this is where the form takes time to load/display
2b: side note: it does nto display this from till the data retirved is complete

3: report form popsup with data and time has pased looking like nothing happened

so id like to have a proress or wait while loading something to say hey im getting this data its gonna take a bit please wait


thanks
Pern
ps: i know theres alot of answers for this but non seamed to fit or worked forme
plus i dint get where to put code please explin where things go too thx alot
0
Comment
Question by:Johnny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12008481
haved you tried to use doevents and timer control?
0
 
LVL 14

Expert Comment

by:aelatik
ID: 12008511
1. First of all, put everything from FORM_LOAD event in an own defined function.
   
    Something like :
    Function FORM_START()
       ' Your code with loops etc.
    End Function

2. Place a timer control and set its interval to 1000, so that it will trigger after 1 second.
3. Put the following code in the timer control.
   
   Private Sub Timer1_Timer()
    Timer1.Enabled = False ' disable the timer after first time because we don't need it anymore
    Call FORM_START
   End Sub

4. Implement the progressbar in the loops, like following :

    progressbar1.min = 0
    progressbar1.max = 28
    For i = 0 to 28
      progressbar1.value = i
      Doevents
    next i
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12008843
You may try something simple like this on the form which is loading...

Private Sub Form_Load()
   
    Dim i As Long
    Me.Caption = "Loading, please wait"
    Me.Show
    DoEvents
    For i = 1 To 2000
        'some loading process
        Debug.Print "loop " & CStr(i)
    Next
    Me.Caption = "Form1"
   
End Sub
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 1500 total points
ID: 12009314
A little modification which displays a progressbar while the form loads, then hides it...

Private Sub Form_Load()
   
    Dim i As Long
    Me.Caption = "Loading, please wait"
    Me.Show
    DoEvents
    With ProgressBar1
    .Visible = True
    .Max = 28 'Set the max value to match the loop number below
    For i = 1 To 28
        'some process
        Debug.Print "Progress " & CStr(i)
        'Call Sleep(300)
        'Update the progress bar
        .Value = i
        .Refresh
    Next
    .Visible = False
    End With
    Me.Caption = "Form1"
   
End Sub
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 23 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question