Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
lsnoble lsnoble is offline
external usenet poster
 
Posts: 2
Default using DateAdd function in a Word form field

I've bashed my head against this all day, and gee, my head hurts! I've
pulled out an awful lot of my hair over this problem. Hope someone can
help with this:

I've created a residential lease contract as a simple form where users
can input basic data involved in the lease agreement, such as Lessor's
name, Lessee's name, and so forth. In the terms of the lease, I want
users to be able to enter the start date of the lease (e.g., March 1,
2007), but I want the end date to be calculated automatically in the
next field so that the end date is one year from the start date (e.g.,
February 28, 2008). I've read what seems like volumes of material about
using the DateAdd function in VBA, which should allow me to run a macro
with this code OnExit from the start date field, but none of the code
I've tried works! GAAAAHH! I'm not at all familiar with using VBA, so I
don't understand how and where to type the code for the DateAdd
function.

The best work-around I've found is to create separate fields for the
years (i.e., a field for "March 1" and a field for "2007), then add a
formula to the field where I want to force the year to update by 1.
Easy, but my client doesn't seem satisfied with this. The client wants
the form to be as error-proof as possible, and doesn't even want users
to have to type in "February 28" (for example).

I would really appreciate some help with this, since I don't have much
hair left.

L.

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default using DateAdd function in a Word form field

See http://www.wopr.com/cgi-bin/w3t/show...?Number=249902
the examples can be modified to suit your requirements

--

Graham Mayor - Word MVP

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


lsnoble wrote:
I've bashed my head against this all day, and gee, my head hurts! I've
pulled out an awful lot of my hair over this problem. Hope someone can
help with this:

I've created a residential lease contract as a simple form where users
can input basic data involved in the lease agreement, such as Lessor's
name, Lessee's name, and so forth. In the terms of the lease, I want
users to be able to enter the start date of the lease (e.g., March 1,
2007), but I want the end date to be calculated automatically in the
next field so that the end date is one year from the start date (e.g.,
February 28, 2008). I've read what seems like volumes of material
about using the DateAdd function in VBA, which should allow me to run
a macro with this code OnExit from the start date field, but none of
the code I've tried works! GAAAAHH! I'm not at all familiar with
using VBA, so I don't understand how and where to type the code for
the DateAdd function.

The best work-around I've found is to create separate fields for the
years (i.e., a field for "March 1" and a field for "2007), then add a
formula to the field where I want to force the year to update by 1.
Easy, but my client doesn't seem satisfied with this. The client wants
the form to be as error-proof as possible, and doesn't even want users
to have to type in "February 28" (for example).

I would really appreciate some help with this, since I don't have much
hair left.

L.



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
lsnoble lsnoble is offline
external usenet poster
 
Posts: 2
Default using DateAdd function in a Word form field

Thank you for your quick reply!

However, I have gone over this document very carefully, and it
unfortunately doesn't contain the information that I need. Thanks so
much, anyway, for your input.

L.

Graham Mayor wrote:
See http://www.wopr.com/cgi-bin/w3t/show...?Number=249902
the examples can be modified to suit your requirements

--

Graham Mayor - Word MVP

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


lsnoble wrote:
I've bashed my head against this all day, and gee, my head hurts! I've
pulled out an awful lot of my hair over this problem. Hope someone can
help with this:

I've created a residential lease contract as a simple form where users
can input basic data involved in the lease agreement, such as Lessor's
name, Lessee's name, and so forth. In the terms of the lease, I want
users to be able to enter the start date of the lease (e.g., March 1,
2007), but I want the end date to be calculated automatically in the
next field so that the end date is one year from the start date (e.g.,
February 28, 2008). I've read what seems like volumes of material
about using the DateAdd function in VBA, which should allow me to run
a macro with this code OnExit from the start date field, but none of
the code I've tried works! GAAAAHH! I'm not at all familiar with
using VBA, so I don't understand how and where to type the code for
the DateAdd function.

The best work-around I've found is to create separate fields for the
years (i.e., a field for "March 1" and a field for "2007), then add a
formula to the field where I want to force the year to update by 1.
Easy, but my client doesn't seem satisfied with this. The client wants
the form to be as error-proof as possible, and doesn't even want users
to have to type in "February 28" (for example).

I would really appreciate some help with this, since I don't have much
hair left.

L.


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default using DateAdd function in a Word form field

Hi lsnoble,

In the document Graham referred you to, the field under the heading
'Calculate a day, date, month and year, using n (301) days delay' can be
used. It just takes a little lateral thinking.

The following is predicated on you setting up the Section of the document
with the date calculation as a protected form:
1. At the point in your document where you want to enter the start date of
the lease-
a) insert a formfield to gather that information;
b) modify the formfield's properties to require a date input in the
desired format;
c) give the formfield a bookmark name (eg 'StartDate'); and
d) set the formfield's properties to 'calculate on Exit'.
2. Insert the field under the heading 'Calculate a day, date, month and
year, using n days delay' at the point in your document where you want to
output the end date of the lease
3. Edit that field (Press Shift-F9 to expose the code) by-
a) changing the contents of the field coded as '{SET Delay 301}' to '{SET
Delay -1}';
b) inserting '+1' after {DATE \@ yyyy} (ie to give ({DATE \@ yyyy}+1');
and
c) changing all instances of 'DATE' to 'StartDate' (or whatever bookmark
name you chose for the formfield).

Subject to any regional date output format changes you might need to make
(see the 'Date input/output formats' in the 'Introductory Notes'), the field
will now be ready for use.

Cheers

--
macropod
[MVP - Microsoft Word]


"lsnoble" wrote in message
oups.com...
Thank you for your quick reply!

However, I have gone over this document very carefully, and it
unfortunately doesn't contain the information that I need. Thanks so
much, anyway, for your input.

L.

Graham Mayor wrote:
See http://www.wopr.com/cgi-bin/w3t/show...?Number=249902
the examples can be modified to suit your requirements

--

Graham Mayor - Word MVP

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


lsnoble wrote:
I've bashed my head against this all day, and gee, my head hurts! I've
pulled out an awful lot of my hair over this problem. Hope someone can
help with this:

I've created a residential lease contract as a simple form where users
can input basic data involved in the lease agreement, such as Lessor's
name, Lessee's name, and so forth. In the terms of the lease, I want
users to be able to enter the start date of the lease (e.g., March 1,
2007), but I want the end date to be calculated automatically in the
next field so that the end date is one year from the start date (e.g.,
February 28, 2008). I've read what seems like volumes of material
about using the DateAdd function in VBA, which should allow me to run
a macro with this code OnExit from the start date field, but none of
the code I've tried works! GAAAAHH! I'm not at all familiar with
using VBA, so I don't understand how and where to type the code for
the DateAdd function.

The best work-around I've found is to create separate fields for the
years (i.e., a field for "March 1" and a field for "2007), then add a
formula to the field where I want to force the year to update by 1.
Easy, but my client doesn't seem satisfied with this. The client wants
the form to be as error-proof as possible, and doesn't even want users
to have to type in "February 28" (for example).

I would really appreciate some help with this, since I don't have much
hair left.

L.




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
Reveal codes in a word document FUN101 Microsoft Word Help 4 May 16th 23 08:47 PM
Word & WordPerfect MrsMac Microsoft Word Help 5 June 10th 06 03:14 AM
hard space between words. Sandy L Microsoft Word Help 7 May 5th 06 08:25 PM
Fill-in field prompts Deb McLellan New Users 7 March 13th 06 08:43 PM
WP merge file to Word sstires Tables 4 February 14th 06 06:26 PM


All times are GMT +1. The time now is 01:02 AM.

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"