Hello people
I was tempted to ask for help, since i end up trying to create some conditions a little more specific but after many hours of researching and reading i learned to catch my own fish thanks to you all people c:
I was able to create the following code:
Code:
Option Explicit
Sub ExclusiveCheckBoxes()
Dim strTemp As String
Dim oFF As FormField
Dim strGrpID As String
Dim strSeqID As String
Dim i As Long
Dim strSeqNext As String
strTemp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Set oFF = Selection.FormFields(1)
If oFF.CheckBox.Value = True Then
strGrpID = Left(oFF.Name, 8)
strSeqID = UCase(Right(oFF.Name, 1))
If strSeqID Like "[A-Z]" Then
'Clear all GroupID ChkBoxes including the CB selected (ensure only one CB in group is selected).
For i = 1 To Len(strTemp)
strSeqNext = strGrpID & "_" & Mid(strTemp, i, 1)
If ActiveDocument.Bookmarks.Exists(strSeqNext) Then
ActiveDocument.FormFields(strSeqNext).CheckBox.Value = False
End If
Next i
'Set the CB that was selected
oFF.CheckBox.Value = True
End If
End If
SetCheck
lbl_Exit:
Exit Sub
End Sub
Sub SetCheck()
Dim bChecked As Boolean
bChecked = False
With ActiveDocument
If .FormFields("CHK_1234_A").CheckBox.Value Or .FormFields("CHK_2345_A").CheckBox.Value Then .FormFields("PVresult").CheckBox.Value = True Else .FormFields("PVresult").CheckBox.Value = False
If Not .FormFields("PVresult").CheckBox.Value Then
.FormFields("PVresult").CheckBox.Value = bChecked
End If
End With
End Sub
Which allow me to have the following conditions:
If at least 1 of the 2 "Yes" Checkbox its market, mark PV box, if no "Yes" box its checked, PV box will be unchecked aswell.
If both "No" Boxes are checked, PV box will be unckecked too.
Only one box per group can be marked, so you cant have "Yes" and "No" box maked on the same Line.
Love you all ppl <3, any tip you guys think that could be useful go ahead, thanks alot for the help.