Progress Bar Control

D

Dave F

Does anyone have some sample code or a good reference for use of the ActiveX
Progress Bar control in Access 2003?

I am processing a large set of records and I want to display the progress to
the user.

I added the ActiveX MS ProgressBar Control version 6.0 to my Access form but
I am not clear on the properties and methods it uses. Conceptually it's
pretty simple. I have a count of records and a loop that processes each
record. So I know the total amount of work to be done (number of records)
and I know my status at any given time (my incremental counter). It seems
that this information would be easy to display graphically. I just don't
know how to work the control.

Can someone who has worked with the Progress Bar give me some pointers?
 
S

Sandra Daigle

Hi Dave,

I suggest avoiding the ActiveX control because of the issues that arise when
dealing with ActiveX's. Instead you might want to consider using the
built-in Progress meter or build your own.

Following is a simple example of how to use the system progress meter - look
down in the lower left corner to see it working. Create a form with a single
button, then paste this code into the Click event procedure for the button.
Basically you initialize the progress meter with a number that represents
how many intervals there are, then you make successive calls to update the
progress meter with an incremental value. Finally you remove the meter. My
example shows it as used in a looping procedure but you can also adapt this
to a lengthy linear list of tasks.

You can create a more noticable progress meter by using a rectangle control
which you color based on the degree of completion of the task. My example of
this is on www.daiglenet.com/msaccess.htm.

There is also a chapter in the Access Cookbook by Ken Getz, Paul Litwin, and
Andy Baron which describes how to make a reusable progress meter. You can
read this excerpt online at
http://msdn.microsoft.com/library/d.../en-us/dnacbk02/html/odc_cookbookchapter8.asp

FWIW, I also like using the progress meter control from the FMS product
Total Access Components 2000. It has a richer set of features and can be
displayed anywhere on the form. (www.fmsinc.com).

Private Sub Command12_Click()
Dim inti As Integer
'
' Initialize the progress meter
Application.SysCmd acSysCmdInitMeter, "Doing Stuff", 10000

For inti = 1 To 5000
Me.txtCounter = inti
'
' Increment the progress meter on each iteration
Application.SysCmd acSysCmdUpdateMeter, inti
' Occasionaly yield CPU to the OS so other stuff can happen
' the 77 is an arbitrary number - you can tune this however you
' want. You can leave this whole if...then out if you just want the
loop
' to have all CPU till
' it is done
If inti Mod 77 = 0 Then
DoEvents
End If
Next inti
'
' Remove the meter
Application.SysCmd acSysCmdRemoveMeter

End Sub
 
D

Dave F

Thank you very much Sandra. Good info.


Sandra Daigle said:
Hi Dave,

I suggest avoiding the ActiveX control because of the issues that arise when
dealing with ActiveX's. Instead you might want to consider using the
built-in Progress meter or build your own.

Following is a simple example of how to use the system progress meter - look
down in the lower left corner to see it working. Create a form with a single
button, then paste this code into the Click event procedure for the button.
Basically you initialize the progress meter with a number that represents
how many intervals there are, then you make successive calls to update the
progress meter with an incremental value. Finally you remove the meter. My
example shows it as used in a looping procedure but you can also adapt this
to a lengthy linear list of tasks.

You can create a more noticable progress meter by using a rectangle control
which you color based on the degree of completion of the task. My example of
this is on www.daiglenet.com/msaccess.htm.

There is also a chapter in the Access Cookbook by Ken Getz, Paul Litwin, and
Andy Baron which describes how to make a reusable progress meter. You can
read this excerpt online at
http://msdn.microsoft.com/library/d.../en-us/dnacbk02/html/odc_cookbookchapter8.asp

FWIW, I also like using the progress meter control from the FMS product
Total Access Components 2000. It has a richer set of features and can be
displayed anywhere on the form. (www.fmsinc.com).

Private Sub Command12_Click()
Dim inti As Integer
'
' Initialize the progress meter
Application.SysCmd acSysCmdInitMeter, "Doing Stuff", 10000

For inti = 1 To 5000
Me.txtCounter = inti
'
' Increment the progress meter on each iteration
Application.SysCmd acSysCmdUpdateMeter, inti
' Occasionaly yield CPU to the OS so other stuff can happen
' the 77 is an arbitrary number - you can tune this however you
' want. You can leave this whole if...then out if you just want the
loop
' to have all CPU till
' it is done
If inti Mod 77 = 0 Then
DoEvents
End If
Next inti
'
' Remove the meter
Application.SysCmd acSysCmdRemoveMeter

End Sub


--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


Dave said:
Does anyone have some sample code or a good reference for use of the
ActiveX Progress Bar control in Access 2003?

I am processing a large set of records and I want to display the
progress to the user.

I added the ActiveX MS ProgressBar Control version 6.0 to my Access
form but I am not clear on the properties and methods it uses.
Conceptually it's pretty simple. I have a count of records and a
loop that processes each record. So I know the total amount of work
to be done (number of records) and I know my status at any given time
(my incremental counter). It seems that this information would be
easy to display graphically. I just don't know how to work the
control.

Can someone who has worked with the Progress Bar give me some
pointers?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top