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 / September 2007

Tip: Looking for answers? Try searching our database.

Creating Word 2007 Forms and calcluated fields.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sergio - 13 Sep 2007 23:18 GMT
I want to create a Word 2007 form, where I use a DatePicker for the user to
select a date (let's call it WeekEndingDate).  Then I want 7 cells in a table
to be updated with WeekEndingDate - 6, WeekEndingDate - 5, etc...

Is that possible to do without having to use VBA, and if so, how would one
go about doing that?  I've exhausted my limited Word Form Development
knowledge. :-)

Thanks,

Sergi
Graham Mayor - 14 Sep 2007 07:16 GMT
It can be done, but it is no simple task to calculate dates in fields.
However fellow MVP 'macropod' has done all the work for you and you can
download his work on date fields from the downloads page of my web site
which you can modify to use your {REF WeekEndingDate} field in place of the
DATE field and set the delay's required in place of the default 14.

Nor is it that difficult to do in vba either. The following, run on exit
from your date field WeekEndingDate, will get the content from
WeekEndingDate and subtract 6 and 5 days and paste the results in Textfields
Text1 and Text2 which should both have the property Fill-in enabled
unchecked

Sub GetContent()
Dim oFld As FormFields
Dim dWEDate As Date
Dim dDate1 As Date
Dim dDate2 As Date
'etc

Set oFld = ActiveDocument.FormFields
dWEDate = oFld("WeekEndingDate").Result
dDate1 = Format(dWEDate - 6, "dd/MM/yyyy")
dDate2 = Format(dWEDate - 5, "dd/MM/yyyy")
'etc
oFld("Text2").Result = dDate1
oFld("Text3").Result = dDate2
'etc
End Sub

Signature

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

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

> I want to create a Word 2007 form, where I use a DatePicker for the
> user to select a date (let's call it WeekEndingDate).  Then I want 7
[quoted text clipped - 8 lines]
>
> Sergi

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.