Reply
 
Thread Tools Display Modes
  #1   Report Post  
Anne Troy
 
Posts: n/a
Default Calculated fields are doubled.

Word 2000 & 2003. We've got form fields with bookmark names, like Fee and
Expenses. Even a simple calc like =Gross-(Fee+Expenses+TotalDeductions)

I am sure I've seen this before working a helpdesk, but I don't remember the
answer.

If you like, you can have a look at the file he
http://www.myexpertsonline.com/downloads/calcs.doc

There is no code in the document.

Thanks very much!
*******************
~Anne Troy

www.OfficeArticles.com



  #2   Report Post  
Andrea Jones
 
Posts: n/a
Default

It's because when the calculation looks at a form field like your 'Total
Deductions' it runs the contents of that form field again thus doubling its
result. You can get the correct answer in your form by doing something like
=Gross-(Gross*Contingency)-CostsAdvanced-Postage-Copies-Telephone-Administrative-FinanceCharges-Amount1-Amount2-Amount3-Amount4.

Personally I would use a macro that runs as you exit each form field and
recalculates everything:

Sub calcmacro()
Dim x As Double
Dim y As Double
Dim tot As Double
x=0
y=0
tot=0
x=Val(ActiveDocument.FormFields("Val1").Result)
y=Val(ActiveDocument.FormFields("Val2").Result)
tot=x+y
ActiveDocument.FormFields("Total").Result=tot
End Sub

The above macro will total two form fields bookmarked Val1 and Val2 and put
the answer in the form field bookmarked Total. Set the calcmacro to run on
exiting every form field. The form fields must be of a number or text type
(the Val function will make it work even on text fields but currency doesn't
work). The Val part also deals with any rounding problems you may get from
adding taxes so your total is the expected answer.

Andrea Jones
http://www.allaboutoffice.co.uk
http://www.stratatraining.co.uk
http://www.allaboutclait.com


"Anne Troy" wrote:

Word 2000 & 2003. We've got form fields with bookmark names, like Fee and
Expenses. Even a simple calc like =Gross-(Fee+Expenses+TotalDeductions)

I am sure I've seen this before working a helpdesk, but I don't remember the
answer.

If you like, you can have a look at the file he
http://www.myexpertsonline.com/downloads/calcs.doc

There is no code in the document.

Thanks very much!
*******************
~Anne Troy

www.OfficeArticles.com




  #3   Report Post  
Doug Robbins
 
Posts: n/a
Default

In a formfield calculation, you cannot use a formfield that contains the
result of another calculation.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
"Anne Troy" wrote in message
...
Word 2000 & 2003. We've got form fields with bookmark names, like Fee and
Expenses. Even a simple calc like =Gross-(Fee+Expenses+TotalDeductions)

I am sure I've seen this before working a helpdesk, but I don't remember
the
answer.

If you like, you can have a look at the file he
http://www.myexpertsonline.com/downloads/calcs.doc

There is no code in the document.

Thanks very much!
*******************
~Anne Troy

www.OfficeArticles.com





  #4   Report Post  
Anne Troy
 
Posts: n/a
Default

THAT's the answer I wanted. Thanks!!
*******************
~Anne Troy

www.OfficeArticles.com


"Doug Robbins" wrote in message
...
In a formfield calculation, you cannot use a formfield that contains the
result of another calculation.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
"Anne Troy" wrote in message
...
Word 2000 & 2003. We've got form fields with bookmark names, like Fee

and
Expenses. Even a simple calc like =Gross-(Fee+Expenses+TotalDeductions)

I am sure I've seen this before working a helpdesk, but I don't remember
the
answer.

If you like, you can have a look at the file he
http://www.myexpertsonline.com/downloads/calcs.doc

There is no code in the document.

Thanks very much!
*******************
~Anne Troy

www.OfficeArticles.com







  #5   Report Post  
Anne Troy
 
Posts: n/a
Default

Thanks, Andrea. I will make this suggestion to the person that asked.
*******************
~Anne Troy

www.OfficeArticles.com


"Andrea Jones" wrote in message
...
It's because when the calculation looks at a form field like your 'Total
Deductions' it runs the contents of that form field again thus doubling

its
result. You can get the correct answer in your form by doing something

like

=Gross-(Gross*Contingency)-CostsAdvanced-Postage-Copies-Telephone-Administra
tive-FinanceCharges-Amount1-Amount2-Amount3-Amount4.

Personally I would use a macro that runs as you exit each form field and
recalculates everything:

Sub calcmacro()
Dim x As Double
Dim y As Double
Dim tot As Double
x=0
y=0
tot=0
x=Val(ActiveDocument.FormFields("Val1").Result)
y=Val(ActiveDocument.FormFields("Val2").Result)
tot=x+y
ActiveDocument.FormFields("Total").Result=tot
End Sub

The above macro will total two form fields bookmarked Val1 and Val2 and

put
the answer in the form field bookmarked Total. Set the calcmacro to run

on
exiting every form field. The form fields must be of a number or text

type
(the Val function will make it work even on text fields but currency

doesn't
work). The Val part also deals with any rounding problems you may get

from
adding taxes so your total is the expected answer.

Andrea Jones
http://www.allaboutoffice.co.uk
http://www.stratatraining.co.uk
http://www.allaboutclait.com


"Anne Troy" wrote:

Word 2000 & 2003. We've got form fields with bookmark names, like Fee

and
Expenses. Even a simple calc like =Gross-(Fee+Expenses+TotalDeductions)

I am sure I've seen this before working a helpdesk, but I don't remember

the
answer.

If you like, you can have a look at the file he
http://www.myexpertsonline.com/downloads/calcs.doc

There is no code in the document.

Thanks very much!
*******************
~Anne Troy

www.OfficeArticles.com






Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Having multiple form fields automatically updated jrwaguespack Microsoft Word Help 3 March 25th 05 07:43 AM
Custom Fields in Word 2002 (XP) [email protected] Microsoft Word Help 1 January 20th 05 03:46 AM
Attempting to auto-update fields in a word document Sanin R Microsoft Word Help 1 January 7th 05 06:39 PM
Using MAILMERGE fields within HYPERLINK fields for Merge to Email Mark V Mailmerge 2 December 4th 04 04:01 PM
posting data from text input fields to fields later in document BOB Microsoft Word Help 1 November 23rd 04 06:19 PM


All times are GMT +1. The time now is 10:37 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"