View Single Post
 
Old 02-22-2015, 08:39 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

I see what you mean. Actually there is no real change event for the checkbox. With it running on entry it will detect a state change if you click the checkbox. However, if you then change your mind and click it again, your tally will not update. It would be best to run the macro OnEntry and OnExit.

Code:
Sub TallyTicks()
'A basic Word macro coded by Greg Maxey
Dim lngGroup As Long
Dim lngIndex As Long
Dim lngTally As Long
  lngGroup = Mid(Selection.FormFields(1).Name, 4, 1)
  For lngIndex = 1 To 6
    If ActiveDocument.FormFields("grp" & lngGroup & "Chk" & lngIndex).CheckBox.Value = True Then
      lngTally = lngTally + 1
    End If
  Next lngIndex
  ActiveDocument.FormFields("grp" & lngGroup & "Tally").Result = CStr(lngTally)
  Select Case lngTally
    Case 1 To 2
      ActiveDocument.FormFields("grp" & lngGroup & "Tally").Range.Font.ColorIndex = wdGreen
      MsgBox "A message for this low score."
    Case Is > 2
      ActiveDocument.FormFields("grp" & lngGroup & "Tally").Range.Font.ColorIndex = wdRed
      MsgBox "A message for this higher score"
    Case Else
      ActiveDocument.FormFields("grp" & lngGroup & "Tally").Range.Font.ColorIndex = wdAuto
  End Select
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote