Progress Bar for Counting Checkboxes

KriXx

New member
Local time
Today, 09:38
Joined
May 24, 2017
Messages
4
Gurus,

Appreciate if you can point me the right direction on creating a progress bar similar to the link below.

codepen.io/jamesbarnett/pen/ybvLB

I have tried several examples but struggling on VBA to make it work.

Thank you in advance.

Cris
 
Do you want to count checkboxes on a form?
Or in a table?
I don't see it being productive. It would take a second,unless you are counting a million.
 
Do you want to count checkboxes on a form?
Or in a table?
I don't see it being productive. It would take a second,unless you are counting a million.

On a form. I am doing a report that for any completed project or task the checkbox needs to be ticked. Based on the number of boxes ticked I will have a progress bar on top.

I am working on the logic of this code and see if I can convert to VBA. But, any help I would appreciate.

Code:
Private Sub Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ProgressBar1.Maximum = 3
    End Sub

    Private Sub CheckBox_CheckedChanged(sender As Object, e As EventArgs) Handles _
        CheckBox1.CheckedChanged, _
        CheckBox2.CheckedChanged, _
        CheckBox3.CheckedChanged

        Dim Count As Integer = 0
        If CheckBox1.Checked Then Count += 1
        If CheckBox2.Checked Then Count += 1
        If CheckBox3.Checked Then Count += 1

        Progressbar1.value = Count

    End Sub
 
Thank You Uncle Gizmo. I have a similar code in the video that I use that when a text box value is zero it will not be clickable.

Code:
Private Sub Form_Current()
Dim ctl As Control
For Each ctl In Me
    If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
        If Nz(ctl, "") = 0 Then
            ctl.Enabled = False
        End If
    End If
Next
End Sub

I will use your 2nd example on check boxes and see if it will sort me out. Again, thank you.
 
Last edited:
Incidentally,
Code:
Count +=1
is not valid syntax in vba
Use
Code:
Count = count + 1
Actually, count is a reserved word. I'd rename the variable to say, intCount

As to displaying a progress bar, you can use Access's internal progress bar - lookup
cmdsys(acsysCmdInitMeter....)

or create your own bar by adding a rectangle to your form and setting the width.

ie
Code:
 me.bxRectangle.width = intCount*567
will set the bar to intCount centimeters
 

Users who are viewing this thread

Back
Top Bottom