Hello all
I am using Word Forms to set up a form for users to fill in.(I know all about Info Path and web based options but am restricted by availability and access rights.)
Here goes the process:
The user completes a single checkbox on each row.
Once a single box( Named Scheck11, SCheck12, SCheck13 for row 1) in the row has been completed I need to move the focus for the sub down to the next row i.e. Scheck21, 22, 23 and so on through the form.
I have built in a check so that only one box can be checked and I think this is why Ive tied myself in knots for the loop. If its true it clears the box and then needs to move on it doesnt in spite of trying different loops and increment options.
Anyway heres one version of the code any ideas, I can think it but not write it:
Sub checkres()'checks the result of the ticked SCheck
For j = 1 To 2 ' for the row number in word table
For i = 1 To 3 ' for the checkbox number on the row
Let k = j 'sets k so we know which row its on to use when clearing
If FormFields("SCheck" & j & i).Result = True Then
FormFields("SCheck" & j & i).EntryMacro = "clearbox"
FormFields("SCheck" & j & i).EntryMacro = "clearbox"
FormFields("SCheck" & j & i).EntryMacro = "clearbox"
MsgBox "Please select only one box. Click OK and try again", vbInformation, "Entry error."
clearbox 'goes to macro to tidy up error
Else
End If
'clearbox
Next i
Next j
End Sub
Sub clearbox() 'counts through and clears all checkboxes on the row to resolve double entry problem
For x = 1 To 3 ' represents the checkbox on the row.
FormFields("SCheck" & k & x).Result = False ' k row value set from j in above sub checkres
Next x
checkres 'returns to results checking sub
End Sub
Many thanks in advance.
Neil
I am using Word Forms to set up a form for users to fill in.(I know all about Info Path and web based options but am restricted by availability and access rights.)
Here goes the process:
The user completes a single checkbox on each row.
Once a single box( Named Scheck11, SCheck12, SCheck13 for row 1) in the row has been completed I need to move the focus for the sub down to the next row i.e. Scheck21, 22, 23 and so on through the form.
I have built in a check so that only one box can be checked and I think this is why Ive tied myself in knots for the loop. If its true it clears the box and then needs to move on it doesnt in spite of trying different loops and increment options.
Anyway heres one version of the code any ideas, I can think it but not write it:
Sub checkres()'checks the result of the ticked SCheck
For j = 1 To 2 ' for the row number in word table
For i = 1 To 3 ' for the checkbox number on the row
Let k = j 'sets k so we know which row its on to use when clearing
If FormFields("SCheck" & j & i).Result = True Then
FormFields("SCheck" & j & i).EntryMacro = "clearbox"
FormFields("SCheck" & j & i).EntryMacro = "clearbox"
FormFields("SCheck" & j & i).EntryMacro = "clearbox"
MsgBox "Please select only one box. Click OK and try again", vbInformation, "Entry error."
clearbox 'goes to macro to tidy up error
Else
End If
'clearbox
Next i
Next j
End Sub
Sub clearbox() 'counts through and clears all checkboxes on the row to resolve double entry problem
For x = 1 To 3 ' represents the checkbox on the row.
FormFields("SCheck" & k & x).Result = False ' k row value set from j in above sub checkres
Next x
checkres 'returns to results checking sub
End Sub
Many thanks in advance.
Neil