Displaying consecutive Dates On A Form

C

ChrisM

MSWord 2000, XP Professional

Hi,

I have a document that is basically a form with a section for each day of
the week.
Currently, every week I have to change all seven dates before printing the
document. What I would like is to be able to enter the first date and have
all the rest calculated automatically.
I have got as far as a single Form Field to enter the first date. I'm now
trying to insert Formula fields for the rest.
The FirstDate (Form Field) is defined as type 'Date', is set to 'Calculate
on Exit' and has a name in the BookMark field setting ('MyDate')
The first Formula Field looks somthing like {=MyDate+1 \@"dd/MM/yy}.
I then set document protection to 'Forms'
When I enter a date in the FormField, the formula field changes to TODAYS
date, regardless of the FormField date. Anyone help me out here?

Note: It has to be a entered date, and not based on the current date, as it
can vary when this form is required, and the start date is not usually
todays date, or a fixed deviation from it.

Cheers,

ChrisM.
 
M

macropod

Hi Chris,

You could do this sort of thing with formula fields, and the topic
'Calculate a Stepped Date Range' in my Date Calc 'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902
shows how one might go about this. If you look it up, you'll find the field
computations are far more complex than one might expect - because Word
wasn't designed with this sort of thing in mind.

For your purposes, a macro driven by the 'run macro on exit' property might
do the job with a lot less bother. For starters, the new dates could be
calculated by the vba DateAdd function, which does in one line of code what
umpteen lines of field coding are otherwise required for. For example,
supposing your formfield names are 'Text1' to 'Text7', you could use
something like:

Sub CalcDates()
Dim iDate As Date
Dim i As Integer
With ActiveDocument
If IsDate(.FormFields("Text1").Result) Then
iDate = CDate(.FormFields("Text1").Result)
For i = 2 To 7
iDate = CDate(iDate + 1)
.FormFields("Text" & i).Result = iDate
Next
Else
MsgBox ("Enter a valid date.")
End If
End With
End Sub

Cheers
 
C

ChrisM

Thanks for your replays.
How crazy is that calculation...??!

Will go to plan B(as suggested) and write a little VBA macro.
.... or maybe just stick to filling the dates in by hand!! :-(

Thanks again,

ChrisM
 
G

Graham Mayor

Just copy the field code from macropod's document and change the final
switch and the delay.

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Or maybe even use the code in supplied in my previous post in this thread
....

Cheers
 
C

ChrisM

macropod said:
Or maybe even use the code in supplied in my previous post in this thread
...

My specific example was slightly more complicated than how I explained it. I
was just after a basic technique. However, I have written a little macro now
(based on your code, thanks) and all is good...
Only problem now is that the guy who will be using it has 'high security'
set on his PC, and it won't run Word macros. Have to try and convince him
that he won't become infested with viruses if he enables them.
Cheers,
ChrisM.
 
M

macropod

Hi Chris,

In that case, you still have the field code version as a last resort - macro
settings don't apply to fields!

Cheers
 
D

Doug Robbins - Word MVP

Create the form as a template and have him save it in his templates folder.
Then it will be considered as trusted and will not given an macro warning
when he creates a new document from it by selecting New from the File menu
and selecting the template.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - 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

Similar Threads


Top