BostonVB
08-11-2011, 10:04 AM
Hello,
I'm trying to figure out a way to count the responses ("Y") of 15 different forms Fields.
FormFields= ProbMed_1,ProbMed_2, ProbMed_n...15
I simply need to count the number of the ProbMed_n form fields with a Y and put that total in form field 'TotProblemMeds'
The code I'm starting with is:
Sub Recalc_Med_Problems()
Dim i, ProblemMeds As Integer
Dim TotProblemMeds, iStr, BkMark As String
ProblemMeds = 0
i = 1
Do While i < 16
iStr = Str(i)
BkMark = "ProbMed_" & iStr
TotProblemMeds = ActiveDocument.FormFields(BkMark).Result
If TotProblemMeds = "Y" Then ProblemMeds = ProblemMeds + 1
i = i + 1
Loop
' Place the total Problem Medications found into the TotProblemMeds field on the document.
ActiveDocument.FormFields("TotProblemMeds").Result = ProblemMeds
End Sub
Thoughts?
I'm trying to figure out a way to count the responses ("Y") of 15 different forms Fields.
FormFields= ProbMed_1,ProbMed_2, ProbMed_n...15
I simply need to count the number of the ProbMed_n form fields with a Y and put that total in form field 'TotProblemMeds'
The code I'm starting with is:
Sub Recalc_Med_Problems()
Dim i, ProblemMeds As Integer
Dim TotProblemMeds, iStr, BkMark As String
ProblemMeds = 0
i = 1
Do While i < 16
iStr = Str(i)
BkMark = "ProbMed_" & iStr
TotProblemMeds = ActiveDocument.FormFields(BkMark).Result
If TotProblemMeds = "Y" Then ProblemMeds = ProblemMeds + 1
i = i + 1
Loop
' Place the total Problem Medications found into the TotProblemMeds field on the document.
ActiveDocument.FormFields("TotProblemMeds").Result = ProblemMeds
End Sub
Thoughts?