Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Tables / April 2004

Tip: Looking for answers? Try searching our database.

IF statement using checkboxes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mickey - 22 Apr 2004 14:37 GMT
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 - 23 Apr 2004 05:14 GMT
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

Signature

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

> I am trying to get a calculation in a field that if the
> checkbox is checked calculate if not checked then leave
[quoted text clipped - 7 lines]
> the boxes. Any help would be appreciated.  If this is not
> a possible please notify. Thanks
mickey - 23 Apr 2004 14:13 GMT
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
>-----Original Message-----
>Run the following macro on exit for each of the checkboxes and from the
[quoted text clipped - 13 lines]
>        ElseIf myresult < 0 Then
>            ActiveDocument.FormFields("Text3").Result =
Format(0 - myresult,
>"(##0.00)")
>        Else
[quoted text clipped - 18 lines]
>
>.
Janice - 27 Apr 2004 17:14 GMT
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
 
>-----Original Message-----
>I am trying to get a calculation in a field that if the
[quoted text clipped - 9 lines]
>a possible please notify. Thanks
>.
mickey - 27 Apr 2004 18:14 GMT
You could do that in a macro but I do not know if possible
to do without.  Sorry.  
>-----Original Message-----
>Hello,
[quoted text clipped - 25 lines]
>>
>.
Doug Robbins - Word MVP - 28 Apr 2004 05:48 GMT
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
Signature

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

> Hello,
> I have been creating forms using tables in a word
[quoted text clipped - 22 lines]
> >a possible please notify. Thanks
> >.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.