Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IF statement using checkboxes

625 views
Skip to first unread message

mickey

unread,
Apr 22, 2004, 9:37:59 AM4/22/04
to
I am trying to get a calculation in a field that if the
checkbox is checked calculate if not checked then leave
blank. My bookmark names for the two check boxes are
comptime and pay. They are both in the same table cell. My
formula is {=IF(comptime) = "0" "" {IF(pay) = "0"
(g14+h14) \#"##0.00;(#,##0.00); ""}} The first and last
brackets are done with ctrl f9. I have tried multiply
combinations. If I do not use the check boxes and use a
different field then I can get it to work but not using
the boxes. Any help would be appreciated. If this is not
a possible please notify. Thanks

Doug Robbins - Word MVP

unread,
Apr 23, 2004, 12:14:46 AM4/23/04
to
Run the following macro on exit for each of the checkboxes and from the
formfields in g14 and h14 (assumed here to be Text1 and Text2 and the result
will be displayed in the formfield Text3:

Dim myresult As Double
If ActiveDocument.FormFields("CompTime").CheckBox.Value = False Then
ActiveDocument.FormFields("Text3").Result = ""
Else
If ActiveDocument.FormFields("Pay").CheckBox.Value = False Then
myresult = Val(ActiveDocument.FormFields("Text1").Result) +
Val(ActiveDocument.FormFields("Text2").Result)
If myresult > 0 Then
ActiveDocument.FormFields("Text3").Result = Format(myresult,
"##0.00")
ElseIf myresult < 0 Then
ActiveDocument.FormFields("Text3").Result = Format(0 - myresult,
"(##0.00)")
Else
ActiveDocument.FormFields("Text3").Result = ""
End If
Else
ActiveDocument.FormFields("Text3").Result = ""
End If
End If


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
"mickey" <anon...@discussions.microsoft.com> wrote in message
news:2b5301c4286f$0729b030$a401...@phx.gbl...

mickey

unread,
Apr 23, 2004, 9:13:15 AM4/23/04
to
Thanks but I was trying to get away from using macros. I
am trying to take all of them out of this template.
Thanks again
Mickey
>.
>

Janice

unread,
Apr 27, 2004, 12:14:53 PM4/27/04
to
Hello,
I have been creating forms using tables in a word
document and have used the check boxes also. What I have
been stumbling over is the same question you have but
something more simple. I would like to just add up the
check boxes in the column above. Did you resolve your
question and can you reply if you know the answer? I
can't seem to get any formula to work with the check
boxes. Please help is you know the answer. Thank you!
Janice
>.
>

mickey

unread,
Apr 27, 2004, 1:14:08 PM4/27/04
to
You could do that in a macro but I do not know if possible
to do without. Sorry.
>.
>

Doug Robbins - Word MVP

unread,
Apr 28, 2004, 12:48:38 AM4/28/04
to
Place a text formfield in the cell in which you want the result to be
displayed and change the name of the bookmark assigned to it to SumofChecks.
Then in the properties dialog for each of the checkboxes in the column set
an On Exit macro to run that contains the following code:

Dim i As Long, sumofchecks As Long
sumofchecks = 0
For i = 1 To Selection.Tables(1).Rows.Count - 1
sumofchecks = sumofchecks -
Selection.Columns(1).Cells(i).Range.FormFields(1).CheckBox.Value
Next i
ActiveDocument.FormFields("SumofChecks").Result = sumofchecks

This assumes that there are check boxes in all rows but the last. If there
is no check box in the first row, change For i = 1 to For i = 2


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP

"Janice" <anon...@discussions.microsoft.com> wrote in message
news:4f4e01c42c72$c60c1130$a301...@phx.gbl...

0 new messages