Form Field Calculation

User avatar
arroway
3StarLounger
Posts: 368
Joined: 04 Jan 2012, 22:43

Form Field Calculation

Post by arroway »

I've been asked to create a locked Word03 .dot form which includes (amoungst other things) 3 feilds: a Time start field, a Time End field, and a Total Minutes field (showing the total minutes between the Start and End times). What's being asked is to allow the Start and End times to be user-entered and have the Total Minutes auto-populate on End-Time-Field-Exit and I'm not sure how to do this. Of course the user could fill in all three but that leaves too much room for errors, rounding, guestimations, mismatched formats, and the like on the users part. So I'm wondering if the Total Minutes would be another form field with a macro or would it be a VBA peice or maybe even using a formula and a StyleRef? I'm not sure if it's possible and if it is possible, what's the best practice. Can anyone apply their knowledge to this and come up with a gracefull solution?

Thanks in advance,
Dax
It takes 2 to tango; unless you speak binary; then it takes 10.

User avatar
HansV
Administrator
Posts: 78857
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Form Field Calculation

Post by HansV »

Word MVP (and Lounge member) macropod has written an extensive tutorial on date/time calculations in Word. It's not easy stuff, but it covers everything you'd ever want to do with dates and times in Word. You can download DateCalc.zip from Graham Mayor's download page.
The attached document shows how his field codes can be used to caclulate duration in minutes. To see how it works, unprotect the document (there's no password), and press Alt+F9 to view the field codes.
TimeCalc.doc
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
arroway
3StarLounger
Posts: 368
Joined: 04 Jan 2012, 22:43

Re: Form Field Calculation

Post by arroway »

Cool! Thanks. That should get me well on my way. ~Dax
It takes 2 to tango; unless you speak binary; then it takes 10.