Creating Word 2007 Forms and calcluated fields.

S

Sergio

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
 
G

Graham Mayor

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


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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top