init steps, PBarMode_Percent, "Hey, I'm working here!" ' example call for using progress bar with a looping process In the first example, we’ll use it in a simple for loop. Set pbar = New Form_ProgressBar (or whatever you happened to name your form). We’ll create a new instance of our progress bar like we would any other class object. Now let’s create a new module and use our new progress bar. Public Sub init(steps As Long, Mode As ePBarModeType, Optional strCaption As String = "Loading.") Public Property Get CurrentProgress() As Long Me.boxProgress.Width = (mCurrentProgress / mSteps) * MaxBoxWidth ' boxProgress.Width = a percentage of maximum box width Me.txtStatus = Format(Me.PercentComplete, "#0") & " % Complete" 'format "#0" gives a 1 or 2 digit integer ' format #0 makes a 1 or 2 digit number without decimals ' Updating the CurrentProgress property updates the status of the Progress Bar Public Property Let CurrentProgress(lng As Long) Public Property Get Mode() As ePBarModeType Public Property Let Mode(PBarMode As ePBarModeType) PercentComplete = mCurrentProgress / mSteps * 100 Public Property Get PercentComplete() As Double Private Const MaxBoxWidth As Long = 7200 'maximun boxProgress width ' * to the original author and publish any derivitive of this * ' * whatever you like with the code, but you must give credit * ' * You are free to change, distribute, and pretty much do * ' * Published under Creative Commons Attribution-Share Alike * Go ahead and paste the code below into the vbe under your new progress bar. All of the code I will share with you is based on this fact. We can do things like add properties and call new instances of forms. This whole thing only works because Access Forms are glorified class modules. Now that we have a form to work with, we’ll need to add some code behind it. It will look something like this in design mode. Just keep at it, you’ll get it right eventually. It needs to actually be smaller than the detail area when you’re in design mode. Are you ready for the hard part? You need to adjust the size of the frame of the form to display just the right amount of the detail area. Make sure the control names are set properly, the code relies on those names. You’ll also need to make sure that the Form Property “Pop Up” is set to “Yes”. Set the “Back Style” property of the text box to “Transparent”. Leave just a little bit of space around your rectangle. Go to design mode and resize the detail area and add a rectangle named boxProgress and a text box named txtStatus as shown below. Start with creating a blank unbound form. I needed to create a progress bar that was native to Access and easy to use. I know this one has been hashed over a few times, but all of the examples I’ve seen are either really clunky to use, or rely on an ActiveX control.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |