Set a fomula in text box

G

Guest

I had 3 text boxes in my word file.

text box1 and text box2 is under date format (dd/mm/yy) and text box3 was
the number of day after text box1 - text box2

How to make it if I press the tab button after the text box2. text box3 will
automatic show out the number.
 
G

Graham Mayor

Two issues here:

1. Do not use fields in text boxes. Text boxes are in the drawing layer of
the document and the calculation will not see their content. Use table cells
or frames instead.

2. Calculated date fields in Word are extremely complex - see
http://www.gmayor.com/insert_a_date_other_than_today.htm
If these are form fields that you are tabbing out of, you will need to
insert the appropriate field calculation to find the difference between the
dates. If we assume that the first data field is called Text1 and the second
Text2 then that construction is:

{={SET a{=INT((14-{REF Text2 \@ M})/12)}}{SET b{={REF Text2 \@
yyyy}+4800-a}}{SET c{={REF Text2 \@ M}+12*a-3}}{SET d{REF Text2 \@
d}}{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045}-{SET
a{=INT((14-{REF Text1 \@ M})/12)}}{SET b{={REF Text1 \@ yyyy}+4800-a}}{SET
c{={REF Text1 \@ M}+12*a-3}}{SET d{REF Text1 \@
d}}{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045}\# ,0}

Don't forget to set the calculate on exit check boxes for both date fields.
You can download the master document containing the basis for such
calculations from a link on the referenced page as constructing the above by
hand is open to all kinds of errors

Credit goes to newsgroup contributor Macropod for his excellent work on date
fields.

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

My web site www.gmayor.com

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

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