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 / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Calculation based on Date

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jamie - 26 Jan 2006 21:52 GMT
I am working in Word 2002.

I’m creating a travel claim.  Two different mileage reimbursements can
apply, depending on the date the mileage was incurred.

For mileage before 12/31/05 the reimbursement rate is 0.485.
Mileage after 12/31/05 the reimbursement rate is 0.445

I have a date field (text1), then a filed for the amount of miles traveled
(text2), then a field in which I want either 0.485 or 0.445 to show (text3),
depending on the date in the date field.

Not sure how to go about the coding for this.  I've been trying to do the
calculation within the field properties, but  can't figure out the coding for
the date.  Any assistance will be appreciated.

Thanks!
Signature

Jamie

Karl E. Peterson - 26 Jan 2006 22:00 GMT
> I am working in Word 2002.
>
[quoted text clipped - 11 lines]
> the calculation within the field properties, but  can't figure out
> the coding for the date.  Any assistance will be appreciated.

Q&D:

  If CDate(Text1.Text) >= #12/31/2005# Then
     Rate = 0.485
  Else
     Rate = 0.445
  End If
  Text3.Text = Format$(Rate, "$0.000")

Some error checking may be required, to accomodate your peskier users.
Signature

Working without a .NET?
http://classicvb.org/

Tony Jollans - 27 Jan 2006 14:25 GMT
This is made easier by the comparand being the end of a year.

Set your date field to Calculate on Exit and then add a Field (not a
FormField) like this ...

   { If { Text1 \@ yyyy } > 2005 0.445 0.485 }

Or, if you need to reference this later, you'll need to set, say, Text3, to
the value ...

   { Set Text3 { If { Text1 \@ yyyy } > 2005 0.445 0.485 } }

(note this is instead of having a FormField called Text3)

--
Enjoy,
Tony

> I am working in Word 2002.
>
[quoted text clipped - 15 lines]
> --
> Jamie
Graham Mayor - 27 Jan 2006 15:25 GMT
If it wasn't at the end of the year you could still use the same method,
only the switch would be different :)

eg { If { Text1 \@ yyyyMMdd } > 20051231 0.445 0.485 }

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> This is made easier by the comparand being the end of a year.
>
[quoted text clipped - 29 lines]
>> --
>> Jamie

Rate this thread:






 
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.