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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count of Option Groups

Status
Not open for further replies.

dannyocean

Technical User
Jan 26, 2001
136
US
Hello All,

I have a form that we use for auditing records. What I am needing to do is calculate the score for each audit and I would like this to show up at the bottom of the form.
Option group values
Yes = 1
No = 2
N/A = 3

All questions must be answered. So I am trying to just count the No's. I will take this number and divide by the total number of questions, which is a fixed value.

Any suggestions would be appreciated.

Thanks in advance,

Danny
 
This should get you started.

Paste this into the Declarations Section of your form (Declare your Variables):
Dim frm As Form
Dim ctl As Control
Dim intNo As Integer


Paste this into the On Load event of your form(Identify you Form)::
Set frm = Me

Paste this into the Form's Module(Count how many no's have been selected):
Private Sub CountOptionIsNo()
intNo = 0
For Each ctl In frm.Controls
If ctl.ControlType = acOptionGroup Then
If ctl.Value = 2 Then
intNo = intNo + 1
End If
End If
Next ctl
MsgBox intNo
End Function


Add a Button to your Form then add this to its On Click event:
CountOptionIsNo

This will will tell you how many no's have been clicked.

If this is what you want create a Locked and Disabled Text Box at the bottom of your Form , replace:
MsgBox intNo
With
Me!CreatedControl = Your calculation incorporating intNo (allow for no no's being selected)

Now add this to you Form's On Current event(Update CreatedControl move between Records):
CountOptionIsNo

Grt back to me with any questions and let me know how you get on.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top