Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom field calculations

Status
Not open for further replies.

pease

Programmer
Apr 2, 2009
29
GB
Hi,

I have inherited a large document which needs to be updated annually (it relates to Statutory Payments in UK PAYE). Dates and values need to be updated which is a real pain time wise.

Im looking to automate as much as possible so because a number of things are repeated within the document I started to set up some custom fields.

eg the following is extracted from the document

Test 3

SMP is payable if the person was continuously employed for 26 weeks leading into the QW. This rule is satisfied if part of the 26th week of employment overlaps any day in the QW.

QW 26/09/10
EWC 09/01/11
Employment starts 10/04/10
Input SMP from 31/10/10.


Test 4
SMP is not payable if the employee only has 25 weeks and 6 days employment on the last day in the QW i.e. the Saturday.

QW 26/09/10
EWC 09/01/11
Employment starts 11/04/10
Attempt to input SMP from 31/10/10


In these cases (and a lot more) I have setup a custom field called Employment_Start where I enter the value of 11/04/10, what I would like is to hold a calculation (held as a VBA function) on the QW value (ie in Test 3 it would be 26 weeks before the QW and in Test 4, 25 weeks and 6 days.

This would mean that in future years we just need to update one date and the rest of the test would be automatically calculated.

There are many other examples such as holding a custom field of SMP_Weekly_Rate which would then be used to
a) populate that amount within the document and
b) calculate other values such as 4 weeks SMP = 4 * SMP_Weekly_Rate or a daily rate of SMP_Weekly_Rate / 7.

Ive written the calculations as a handful of functions within VBA however I cant seem to get these to operate on custom fields, calculations seem to be do-able on form fields but as far as I can see not custom fields.

Is this the case? if so, is there any workaround or do I basically need to start again and rework the document using form fields? additionally if the latter is the case, can I duplicate the same form field many times in a document and just update one for all to cascade?

So many questions on what should be a quiet work day!

Merry Christmas to you all and thanks in advance.

Peter
 
What application? This helps, and should always be mentioned.

What - exactly - do you mean by custom fields? Please describe them.

It is likely that a REF field could work for you, but we need specifics.

Gerry
 
Hi Peter,

You can trigger a formfield calculation via a macro attached to the on-exit or on-entry formfield properties.

Many field-based calculations, though, can be done without the need for vba.

For details of how to do a wide range of math calculations in Word, check out my Word Field Maths Tutorial, at:

For details of how to do just about every calculation you might want to do with Dates in Word, check out my Word Date Calculation Tutorial, at:

Do read the documents' introductory material. Both tutorials can also be downloaded from:



Cheers
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top