Originally Posted by
jbeets
Ok - so my questions all have a Yes, No or N/A option.
Hmm…That "N/A" option ruins the "Checkbox" plan.
So, rolling back, the VBA code for the score could be as seems below:
Code:
Private Sub btnDocScore_Click()
Dim c As Control
Dim intYes As Integer
Dim n As Integer
Me!DocScore = Null
For Each c In Me.Controls
If c.ControlType = acComboBox And c.Tag = "Doc" Then
If IsNull(c) Then
MsgBox ("ComboBox selection left blank. Please ensure all drop downs are selected before continuing.")
c.SetFocus
Exit Sub
Else
If c = "Yes" Then
intYes = intYes + 1 'Count only "Yes"
End If
n = n + 1 'Count the total questions
End If
End If
Next c
With Me!DocScore
'Calculate score
.Value = intYes / n 'Is better to set the DocScore's Format to 0% in design view
If Me!cboDocQ2 = "No" Then
.Value = .Value + Me!txtDQ2Var 'Add the variance to the total score
End If
End With
txtDocStatus = "Complete"
'========================================================
'About controls BackColor, better use conditional format
'========================================================
End Sub
Hope this helps.
Cheers,
John