Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Lani
 
Posts: n/a
Default Merge of a calculated date produces an error

I am using Microsoft Word 2002. I copied the following code from
www.addbalance.com (I changed the bookmark name and number of days being
subtracted):

{QUOTE {SET Delay "29"}}{SET "NextPrevMonth" {IF {SALEDATE \@ "MM"} = 1
"12/97" "{ = { SALEDATE \@ "MM"} €“ 1 }/97" }}{SET "DaysInMonth" {IF {
NextPrevMonth \@ "MM"} 2{ = INT(30575*{NextPrevMonth \@ "MM"
}/1000+1/2)-INT(30575*{ ={NextPrevMonth \@ "MM"} €“ 1 }/1000+1/2) }{ IF { =
INT({SALEDATE \@ "yy" }/4) } = { = { SALEDATE \@ "yy"}/4) }"29" "28" } } }{
IF { = {SALEDATE \@ "dd"} €“ {REF Delay \* MERGEFORMAT} } 0{QUOTE {
SALEDATE \@ "MMMM" }" "{ = { SALEDATE \@ "dd" } €“ { REF Delay \* MERGEFORMAT
} \# "0" }", "{ SALEDATE \@ "yyyy"}""}{QUOTE {NextPrevMonth \@ "MMMM" }" "{ =
{ SALEDATE \@ "dd"} €“ ( REF Delay \* MERGEFORMAT} + {DaysInMonth} \# "0"
}", "{ IF { SALEDATE \@ "MM"} 1 { SALEDATE \@ "yyyy"}{ = { SALEDATE \@
"yyyy"} €“ 1 \# "xxxx"}}""}}

When I merge the document with any SALEDATE in March, I receive an error
page that reads "A field calculation error occurred in record 2." When I
close the error page, the document I merged is underneath and the calculation
is correct (unless the SALEDATE is 03/01/2006 then it merges February 0,
2006). I suspect that this has something to do with February only having 28
days. Can anyone tell me what I can do to eliminate the error? Also, as an
added bonus, does anyone know how I can change the code so it won't merge
February 0, 2006?
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor
 
Posts: n/a
Default Merge of a calculated date produces an error

Because of the difficulty in manually reproducing such complex fields there
are a couple of errors in your post that make it even more difficult to read
and if they are exactly culled from your document would contribute to the
error. What exactly are you trying to achieve?

You might do better downloading the most recent version of original document
on which such calculations were based. This is linked from
http://www.gmayor.com/insert_a_date_...than_today.htm (and from
Charles's site)

Paste the code from the source document into your merge document and use
replace to change DATE to Mergefield SALEDATE.

The macro at http://www.gmayor.com/export_field.htm will make the transfer
of field codes to text for messaging much easier.

--

Graham Mayor - Word MVP

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



Lani wrote:
I am using Microsoft Word 2002. I copied the following code from
www.addbalance.com (I changed the bookmark name and number of days
being subtracted):

{QUOTE {SET Delay "29"}}{SET "NextPrevMonth" {IF {SALEDATE \@ "MM"}
= 1 "12/97" "{ = { SALEDATE \@ "MM"} - 1 }/97" }}{SET "DaysInMonth"
{IF { NextPrevMonth \@ "MM"} 2{ = INT(30575*{NextPrevMonth \@ "MM"
}/1000+1/2)-INT(30575*{ ={NextPrevMonth \@ "MM"} - 1 }/1000+1/2) }{
IF { = INT({SALEDATE \@ "yy" }/4) } = { = { SALEDATE \@ "yy"}/4)
}"29" "28" } } }{ IF { = {SALEDATE \@ "dd"} - {REF Delay \*
MERGEFORMAT} } 0{QUOTE { SALEDATE \@ "MMMM" }" "{ = { SALEDATE \@
"dd" } - { REF Delay \* MERGEFORMAT } \# "0" }", "{ SALEDATE \@
"yyyy"}""}{QUOTE {NextPrevMonth \@ "MMMM" }" "{ = { SALEDATE \@ "dd"}
- ( REF Delay \* MERGEFORMAT} + {DaysInMonth} \# "0" }", "{ IF {
SALEDATE \@ "MM"} 1 { SALEDATE \@ "yyyy"}{ = { SALEDATE \@ "yyyy"}
- 1 \# "xxxx"}}""}}

When I merge the document with any SALEDATE in March, I receive an
error page that reads "A field calculation error occurred in record
2." When I close the error page, the document I merged is underneath
and the calculation is correct (unless the SALEDATE is 03/01/2006
then it merges February 0, 2006). I suspect that this has something
to do with February only having 28 days. Can anyone tell me what I
can do to eliminate the error? Also, as an added bonus, does anyone
know how I can change the code so it won't merge February 0, 2006?



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod
 
Posts: n/a
Default Merge of a calculated date produces an error

Hi Lani,

Part of the problem is that the code you're using only works reliably with a
maximum of 28 days. This limitation is mentioned on the site where you
obtained the code.

For a more reliable solution for this and just about everything else you
might want to do with dates in Word, check out my Date Calc 'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902


Cheers


"Lani" wrote in message
...
I am using Microsoft Word 2002. I copied the following code from
www.addbalance.com (I changed the bookmark name and number of days being
subtracted):

{QUOTE {SET Delay "29"}}{SET "NextPrevMonth" {IF {SALEDATE \@ "MM"} = 1
"12/97" "{ = { SALEDATE \@ "MM"} - 1 }/97" }}{SET "DaysInMonth" {IF {
NextPrevMonth \@ "MM"} 2{ = INT(30575*{NextPrevMonth \@ "MM"
}/1000+1/2)-INT(30575*{ ={NextPrevMonth \@ "MM"} - 1 }/1000+1/2) }{ IF { =
INT({SALEDATE \@ "yy" }/4) } = { = { SALEDATE \@ "yy"}/4) }"29"

"28" } } }{
IF { = {SALEDATE \@ "dd"} - {REF Delay \* MERGEFORMAT} } 0{QUOTE {
SALEDATE \@ "MMMM" }" "{ = { SALEDATE \@ "dd" } - { REF Delay \*

MERGEFORMAT
} \# "0" }", "{ SALEDATE \@ "yyyy"}""}{QUOTE {NextPrevMonth \@ "MMMM" }"

"{ =
{ SALEDATE \@ "dd"} - ( REF Delay \* MERGEFORMAT} + {DaysInMonth} \# "0"
}", "{ IF { SALEDATE \@ "MM"} 1 { SALEDATE \@ "yyyy"}{ = { SALEDATE \@
"yyyy"} - 1 \# "xxxx"}}""}}

When I merge the document with any SALEDATE in March, I receive an error
page that reads "A field calculation error occurred in record 2." When I
close the error page, the document I merged is underneath and the

calculation
is correct (unless the SALEDATE is 03/01/2006 then it merges February 0,
2006). I suspect that this has something to do with February only having

28
days. Can anyone tell me what I can do to eliminate the error? Also, as

an
added bonus, does anyone know how I can change the code so it won't merge
February 0, 2006?



  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Lani
 
Posts: n/a
Default Merge of a calculated date produces an error

Thank you for the macro to transfer field codes. That will be very useful in
the future.

I found a date calculation code that works on Woody's Lounge (posted by
macropod). Thank you for your help!

"Graham Mayor" wrote:

Because of the difficulty in manually reproducing such complex fields there
are a couple of errors in your post that make it even more difficult to read
and if they are exactly culled from your document would contribute to the
error. What exactly are you trying to achieve?

You might do better downloading the most recent version of original document
on which such calculations were based. This is linked from
http://www.gmayor.com/insert_a_date_...than_today.htm (and from
Charles's site)

Paste the code from the source document into your merge document and use
replace to change DATE to Mergefield SALEDATE.

The macro at http://www.gmayor.com/export_field.htm will make the transfer
of field codes to text for messaging much easier.

--

Graham Mayor - Word MVP

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



Lani wrote:
I am using Microsoft Word 2002. I copied the following code from
www.addbalance.com (I changed the bookmark name and number of days
being subtracted):

{QUOTE {SET Delay "29"}}{SET "NextPrevMonth" {IF {SALEDATE \@ "MM"}
= 1 "12/97" "{ = { SALEDATE \@ "MM"} - 1 }/97" }}{SET "DaysInMonth"
{IF { NextPrevMonth \@ "MM"} 2{ = INT(30575*{NextPrevMonth \@ "MM"
}/1000+1/2)-INT(30575*{ ={NextPrevMonth \@ "MM"} - 1 }/1000+1/2) }{
IF { = INT({SALEDATE \@ "yy" }/4) } = { = { SALEDATE \@ "yy"}/4)
}"29" "28" } } }{ IF { = {SALEDATE \@ "dd"} - {REF Delay \*
MERGEFORMAT} } 0{QUOTE { SALEDATE \@ "MMMM" }" "{ = { SALEDATE \@
"dd" } - { REF Delay \* MERGEFORMAT } \# "0" }", "{ SALEDATE \@
"yyyy"}""}{QUOTE {NextPrevMonth \@ "MMMM" }" "{ = { SALEDATE \@ "dd"}
- ( REF Delay \* MERGEFORMAT} + {DaysInMonth} \# "0" }", "{ IF {
SALEDATE \@ "MM"} 1 { SALEDATE \@ "yyyy"}{ = { SALEDATE \@ "yyyy"}
- 1 \# "xxxx"}}""}}

When I merge the document with any SALEDATE in March, I receive an
error page that reads "A field calculation error occurred in record
2." When I close the error page, the document I merged is underneath
and the calculation is correct (unless the SALEDATE is 03/01/2006
then it merges February 0, 2006). I suspect that this has something
to do with February only having 28 days. Can anyone tell me what I
can do to eliminate the error? Also, as an added bonus, does anyone
know how I can change the code so it won't merge February 0, 2006?




  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Lani
 
Posts: n/a
Default Merge of a calculated date produces an error

I found a date calculation code that works on your Date Calc 'tutorial'.

I had trouble figuring out why it did not work consistently when I
subtracted dates, but then I found a post explaining that I had to change the
output from d/mm/yyyy to mm/d/yyyy and now it works great. Thank you so much.

"macropod" wrote:

Hi Lani,

Part of the problem is that the code you're using only works reliably with a
maximum of 28 days. This limitation is mentioned on the site where you
obtained the code.

For a more reliable solution for this and just about everything else you
might want to do with dates in Word, check out my Date Calc 'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902


Cheers


"Lani" wrote in message
...
I am using Microsoft Word 2002. I copied the following code from
www.addbalance.com (I changed the bookmark name and number of days being
subtracted):

{QUOTE {SET Delay "29"}}{SET "NextPrevMonth" {IF {SALEDATE \@ "MM"} = 1
"12/97" "{ = { SALEDATE \@ "MM"} - 1 }/97" }}{SET "DaysInMonth" {IF {
NextPrevMonth \@ "MM"} 2{ = INT(30575*{NextPrevMonth \@ "MM"
}/1000+1/2)-INT(30575*{ ={NextPrevMonth \@ "MM"} - 1 }/1000+1/2) }{ IF { =
INT({SALEDATE \@ "yy" }/4) } = { = { SALEDATE \@ "yy"}/4) }"29"

"28" } } }{
IF { = {SALEDATE \@ "dd"} - {REF Delay \* MERGEFORMAT} } 0{QUOTE {
SALEDATE \@ "MMMM" }" "{ = { SALEDATE \@ "dd" } - { REF Delay \*

MERGEFORMAT
} \# "0" }", "{ SALEDATE \@ "yyyy"}""}{QUOTE {NextPrevMonth \@ "MMMM" }"

"{ =
{ SALEDATE \@ "dd"} - ( REF Delay \* MERGEFORMAT} + {DaysInMonth} \# "0"
}", "{ IF { SALEDATE \@ "MM"} 1 { SALEDATE \@ "yyyy"}{ = { SALEDATE \@
"yyyy"} - 1 \# "xxxx"}}""}}

When I merge the document with any SALEDATE in March, I receive an error
page that reads "A field calculation error occurred in record 2." When I
close the error page, the document I merged is underneath and the

calculation
is correct (unless the SALEDATE is 03/01/2006 then it merges February 0,
2006). I suspect that this has something to do with February only having

28
days. Can anyone tell me what I can do to eliminate the error? Also, as

an
added bonus, does anyone know how I can change the code so it won't merge
February 0, 2006?




Reply
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
Date Field Merge George Mathew Mailmerge 3 January 24th 06 10:26 PM
Merge Date Error with change in calendar year Frank Santoro Mailmerge 5 January 11th 06 11:22 AM
How do I omit an empty date merge field? Phildeman Microsoft Word Help 5 June 13th 05 03:29 PM
Wrong mail merge date format sam Mailmerge 1 June 8th 05 01:23 PM
Help! I'm getting error messages too much-can't open Resume Wizard LizLB Microsoft Word Help 0 May 3rd 05 01:46 AM


All times are GMT +1. The time now is 12:39 PM.

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"