Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of Progressbar

Status
Not open for further replies.

33216CLC

Programmer
Aug 17, 2000
173
0
0
BS
I have several procedures in my program code that have more than one Loop events. For example:


'LOOP1
If Not rs.BOF Then

Frmprog.ProgressBar1.Max = cnt
Do While Not rs.EOF
intCounter = intCounter + 1
Frmprog.ProgressBar1.Value = intCounter ' Update progress.
ee_id = rs![Employee Id]
Call SingleProcess
If CancelRun Then Exit Sub
rs.MoveNext
Loop
Unload Frmprog
End If


'LOOP2
sqlquery = "select table1.*, table2.* from table1 inner join table2 on table1.employee_id=table1.[Employee Id] where table1.paydate=#" & USEnd_Date & "# and table1.company_id=" & Company_ID

Set rsVac = dbPayroll.OpenRecordset(sqlquery, dbOpenSnapshot)

If Not rsVac.BOF Then
rsVac.MoveFirst
While Not rsVac.EOF
Vac_id = rsVac!employee_id
CurrentPayNumber = PEDNumber(PayOpt)
If CurrentPayNumber = 0 Then
Exit Sub
End If
Call VacProcess
Loop
rsVac.MoveNext
Wend
End If

As you can see, loop 1 has the progress bar coming up, but loop 2 does not. How can I have the progress bar to appear and remain on screen for the execution of both loops without having to initialize the counter a second time?

Thanks
 
When you are in a loop and need to update the GUI, you need to periodcally yield control via the DoEvents call.

Just be sure to make your sub or function handle the potential of re-enterancy. For example, you push a button on the form to start this process. Inside the button you disable it, run the process, then enable the button again.

If the operation is within a class, use a class level variable to hold the state of a function. Inside the function(or sub) you would check the state, if its set, exit immediately, otherwise you set the state and continue. Just remember to reset the state when the function(sub) is done, or you will lock it out :)

I've done that a couple of times... call 'em head scratchers...

Hope this helps!
 
Hi Iray, I am not very clear on your suggestion. Could you please give me an example (using my code example if you wish).

Thank you
 
Could somebody please explain the suggestion above?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top