How do I add a progress bar?

Using Access97. I want to add to a form and report a simple bar that shows a percentage of time used. Ex: - Employee has 80 hours of vacation a year. They used 20 hours so far. The bar would be a quarter filled with 25% on it. I have this progress bar demo but not sure of how to attach code to make it respond to a calculated field. The demo uses a command button to increment the percentage in the bar. Heres the code for the module:
--------------------------------------
Option Compare Database
Option Explicit

Private Sub Commande1_Click()
   
Me.ctlSbfPBV1.Form.Progress
   
End Sub
--------------------------------------
Private Sub Form_Load()
With Me.ctlSbfPBV1.Form
        .BarColor = vbGreen
        .Orientation = 1
        .Max = 75
    End With
End Sub
--------------------------------------
This demo had about 6 other demos on the form. I took out the code for them.
I hope this is enough information for you.
I will want to use the basic premise to do this with 3 categories on the form once I figure out how to do 1.

Bill
bneumanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ssteevesCommented:
The Progress Bar control that I downloaded works like this.  

Place it on the form, and place this code in a button:

ctlProgress.max = 100
ctlProgress.value = 25
ctlProgress.visible = true

Where ctlProgress is the name of the control.

I don't know if this code will work for you, as I don't know what Progress bar you are using.   The default that ships with Access or different version?

ssteeves
0
ssteevesCommented:
If that code does work, you should be able to substitue the .value line to be equal to the calculated field....
0
bneumanAuthor Commented:
ssteeves,
Thanks for the suggestion but this not what I want. Hopefully someone else will respond.

Bill
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

bneumanAuthor Commented:
Let me add.......I'd like to add that I want the progress bar to be filled in by the results from a combobox. I pick on a selection in the combobox and the results fill in the form. I would like this info to fill in a graphical bar. Not sure if its a progress bar or not.

Bill
0
jschrismanCommented:
As SSteves said, I don't know what progress bar you're using. You did give me enough information to get started though.

In the form's On Load event you want to use the same code-

Private Sub Form_Load()
With Me.ctlSbfPBV1.Form
        .BarColor = vbGreen
        .Orientation = 1
        .Max = 75
    End With
End Sub

Of course, you may want to change the bar color or orientation.

In the form's On Current event you want to use this code-

Private Sub Form_Current()
  Me.ctlSbfPBV1.Form.Max = 100 \ (employeeVacationTime \ employeeVacationUsed)
End With
End Sub

I'm assuming the .Max property sets the length of the bar. Without more information on the specific control you are using that's all I can say.
0
bneumanAuthor Commented:
I get a 'divide by zero' error. When I thought I fixed that I got an error in the Max area of the bar. I found out who developed the bar:
sbfProgressBar
'''
''' Marc CHOUTEAU - Octobre 1998
'''
''' JetSofts - Solution Informatique
''' jetsofts@dlnet-inter.fr
''' marc@dlnet-inter.fr

I found out that much of it is in french. Maybe I will start from scratch. Is there a better way?
0
bneumanAuthor Commented:
Adjusted points to 100
0
bneumanAuthor Commented:
I've abandoned my previous attempt at the progress bar. I've up the points to 100 now. Will take any suggestions to make this work. As I stated before I would like a graphical depiction of time used. In this case there will 3 separate bars. One for VactionUsed, PersonalTimeUSed and Tardiness. On a form I have a comboBox to list employees. Click on employee and subform fills in with employee information. Also on form are calculated fields that show Total Vacation, Vacation Used and Vacation Left. Same with personal time. The tardiness is not currently handled this way. I figure if I can get 1 bar to work I can make the other stuff work too. (wishful thinking!) What I want is when I click on employee in comboBox that the progress bars show vacation used and personal used. Like my previous example if a person has 80 hrs per year and he already took 20 hrs, the bar would be a quarter filled with 25% inside. Does this make sense??? I'll up the points another 50 if need be.
Help......

Bill
0
jschrismanCommented:
Do you have the Microsoft ProgressBar Control v5.0? I have made it work with this control, if you have it I'll show you how.
0
bneumanAuthor Commented:
I have Microsoft ProgressBar Control v6.0.
0
jschrismanCommented:
That'll work.

Try this...

Private Sub Form_Current()
If HoursUsed > 0 Then
  PBar.Value = 100 * (HoursUsed / HoursVacation)
Else
  PBar.Value = 0
End If
End Sub
0
jschrismanCommented:
By the way, you'll obviously have to use this on a control named "PBar".
0
bneumanAuthor Commented:
Ok...great finally got it to work. What a feeling when you click on a control and you don't get a compile error!

I have the vacation time working, now on to personal time used. Here is the code I have to use for vacation time used.

------------------------------------
Private Sub indiv_Change()
If [cVacationUsed] > 0 Then
  PBar.Value = 100 * ([cVacationUsed] / [cVacation])
Else
  PBar.Value = 0
End If
End Sub
-------------------------------------

Next question is how do I get the next Bar to work (PBar2)? I assume its where the End If line is.... something like continue to next,loop or something??

Bill
0
jschrismanCommented:
Exactly. You'll start another If...Then...else right after the end if statement.
0
jschrismanCommented:
You might want to place the progress bar updates in their own subroutine. That way you can call it whenever you want.

Add this to the form's module-

Private Sub UpdatePBars ()
If [cVacationUsed] > 0 Then PBar.Value = 100 * ([cVacationUsed] / [cVacation]) Else PBar.Value = 0
if [othVal2] > 0 Then PBar2.Value = 100 * ([othVal1] / [othVal2]) Else PBar2.Value = 0
if [othVal4] > 0 Then PBar3.Value = 100 * ([othVal3] / [othVal4]) Else PBar3.Value = 0
End Sub

Then use this syntax-

Private Sub indiv_Change()
UpdatePBars
End Sub

Any field which could affect the values of the PBars would have to have an AfterUpdate event added which also calls the above sub.

Private Sub cVacationUsed_AfterUpdate ()
UpdatePBars
End Sub

etc...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bneumanAuthor Commented:
I'm at home now and just got locked out of my computer at work....Maintenance! I won't be able to do anything until tomorrow morning. I'll get back to you then. Thanks for the subroutine idea. I'll try that in the morning.

Bill
0
bneumanAuthor Commented:
jschrisman,

Everything works just the way I wanted. I really appreciate your help. I've increased the points another 50. Thanks again.
Bill
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.