Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.tables
Fred Fred is offline
external usenet poster
 
Posts: 6
Default Display plus or minus signs on calculated table field

I wasn't sure whether this query counted as a table query or a VB
query, so have posted here first.

Using Word 97, I have a word table, that is set to protected (Forms).
In the table there are, amongst others, 2 columns of dates and a third
column which I need to calculate the difference between the dates in
the other two columns.

I have defined the date columns with a Type of Date, both have bookmark
names ITarg1 ...n and CTarg1 ...n the third column is has a Type of
Number, a bookmark of MSDD1 ...n and a format of +#,##0

On exit from the CTarg column I run a macro (DD_MSDD1 ...n) to
calculate the difference and put the result in the third column.

Sub DD_MSDD1()
MilestoneDateDiff "1" 'call to common routine to calc diff for MSDD1
End Sub

Sub MilestoneDateDiff(DD)

Initial = DateValue(ActiveDocument.FormFields("ITarg" & DD).Result)
Current = DateValue(ActiveDocument.FormFields("CTarg" & DD).Result)
days = Format(Current - Initial, ("+#,##0 ;-#,##0"))
ActiveDocument.Unprotect
ActiveDocument.FormFields("MSDD" & DD).Result = days
ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub

What I need to achieve is the difference figure in the third column to
display either as +ddd or -ddd, so far all I can achieve is ddd or
-ddd. I have tried various formats, both within the vb and the cell
format to no avail, ending up with, "(+14)" when there is a negative
difference, (go figure !) or "+28" when there is a positive difference
when I had set the MSDD1 cell with a format of +#,##0;(-#,##0)

I would also like to introduce some degree of checking that there are
values in both ITarg and CTarg cells, if at all possible.

Can anyone help me out with this problem please ?

Thanks and regards
Fred

 
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
mail merging formatted content donna Mailmerge 18 July 28th 06 06:20 PM
Table Format Style vs. Table Text Style WebColin Page Layout 11 December 1st 05 11:29 PM
Document Styles should be assignable to fonts in Table AutoFormat Natasha A. Tables 5 November 11th 05 05:49 PM
Text form field inside WORD table cell, odd selection behavior pwrichcreek Microsoft Word Help 1 October 11th 05 03:57 PM
Table headers/footers and layout Keith Page Layout 1 April 8th 05 07:37 PM


All times are GMT +1. The time now is 09:38 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"