C
cwangosu
This is tied in with my previous message, but I thought I'd try to
explain my situation better.
I have a variety of form fields where a user inputs text or selects a
dropdown and receives points based on this. I have used a variety
of "Cases" to accomplish this. Right now, I have a counter which is
displayed after the last form field is filled in and displays this
total point value as a message box.
Instead what I'd like is for a form field named "Text1" to display
this total point value. Unfortunately, it's not working, because the
form is protected and it gives an error. Any help would be
appreciated...
Here's part of my code...
'=========================================================
Function TotalCount() As Boolean
Dim TotalInteger As Integer
Dim objField As FormField
Dim strFieldName As String
Dim strResult As String
Dim num As Integer
Dim chk As Boolean
For Each objField In ActiveDocument.FormFields
strFieldName = objField.Name
Select Case strFieldName
'txtFirstName, txtLastName, txtPSNum
'Award one point for completion
Case "txtFirstName", "txtLastName", "txtPSNum"
strResult = objField.Result
If strResult <> "" Then
TotalInteger = TotalInteger + 1
'Point Given For Completion
TotalCount = True
End If
'drpChampApprove
'Award three points for champion approval
Case "drpChampApprove"
num = objField.DropDown.Value
If num = 1 Then
'(Select One)
TotalInteger = TotalInteger + 0
MsgBox "You have earned " & TotalInteger & " points for completing
this form "
ElseIf num = 2 Then
'Yes
TotalInteger = TotalInteger + 3
MsgBox "You have earned " & TotalInteger & " points for completing
this form "
Else
'No
TotalInteger = TotalInteger + 0
MsgBox "You have earned " & TotalInteger & " points for completing
this form "
TotalCount = True
End If
Case Else
TotalCount = False
End Select
Next objField
End Function
explain my situation better.
I have a variety of form fields where a user inputs text or selects a
dropdown and receives points based on this. I have used a variety
of "Cases" to accomplish this. Right now, I have a counter which is
displayed after the last form field is filled in and displays this
total point value as a message box.
Instead what I'd like is for a form field named "Text1" to display
this total point value. Unfortunately, it's not working, because the
form is protected and it gives an error. Any help would be
appreciated...
Here's part of my code...
'=========================================================
Function TotalCount() As Boolean
Dim TotalInteger As Integer
Dim objField As FormField
Dim strFieldName As String
Dim strResult As String
Dim num As Integer
Dim chk As Boolean
For Each objField In ActiveDocument.FormFields
strFieldName = objField.Name
Select Case strFieldName
'txtFirstName, txtLastName, txtPSNum
'Award one point for completion
Case "txtFirstName", "txtLastName", "txtPSNum"
strResult = objField.Result
If strResult <> "" Then
TotalInteger = TotalInteger + 1
'Point Given For Completion
TotalCount = True
End If
'drpChampApprove
'Award three points for champion approval
Case "drpChampApprove"
num = objField.DropDown.Value
If num = 1 Then
'(Select One)
TotalInteger = TotalInteger + 0
MsgBox "You have earned " & TotalInteger & " points for completing
this form "
ElseIf num = 2 Then
'Yes
TotalInteger = TotalInteger + 3
MsgBox "You have earned " & TotalInteger & " points for completing
this form "
Else
'No
TotalInteger = TotalInteger + 0
MsgBox "You have earned " & TotalInteger & " points for completing
this form "
TotalCount = True
End If
Case Else
TotalCount = False
End Select
Next objField
End Function