Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / December 2003

Tip: Looking for answers? Try searching our database.

Compare two fields from a data source before inserting text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
harg7769@lineone.net - 22 Sep 2003 16:26 GMT
Is it possible to compare two fields in a data source, and based on
that comparison, enter a specific block of text. I realise that it has
to do with the IF THEN ELSE merge field but I can't seem to get it to
work correctly.

The two fields in the data source are InstDate and Current_Date. If
InstDate >= Current_Date then I want to say ... but if InstDate <
CurrentDate, then I want to say something else.

I went into the Insert Word Field and selected If Then Else. I then
chose the InstDate in the Field Name Box, changed the comparison box
to >= then in Compare To, I have tried typing Current_Date,
{MERGEFIELD Current_Date},
{MERGEFIELD "Current_Date"} but I haven't been able to get it right.

Can I type the code directly instead of using the drop down boxes?

Andrew H
Greg - 22 Sep 2003 17:49 GMT
Andrew,

Yes,  Change the "A" "B" to your field names and this
should work:

{ IF {MERGEFIELD A} >= "{MERGEFIELD B}" "YES" "NO" }
Where {} is entered with insert field brackets CTRL+F9
and "YES" "NO" is substituted for your desired text block.

Delete wha....m to reply in e-mail.

>-----Original Message-----
>Is it possible to compare two fields in a data source, and based on
[quoted text clipped - 16 lines]
>Andrew H
>.
harg7769@lineone.net - 07 Oct 2003 09:50 GMT
Sorry to follow this one up so late, but I'm still trying to get it to
work. At the moment the code I have is as follows:

{IF {InstDate}  >= {CDate} "will soon be out of warranty." "is now out
of warranty"}

The problem is that everything is coming through as TRUE, and so
ievery record shows "will soon be out of warranty", which is obviously
not rue, as it shows the expiry date (InstDate) at the top of the
page. CDate is just today's date.

Does Word have a problem with dates in general? I know that if I try
and use an Excel spreadsheet as a data source and it has dates in it,
then Word will put my dates into the American format, even although I
have them in the British format.

This time I have been using a raw text file as the data source, and
the dates are showing correctly but I get the impression that Word is
struggling to compare dates, and that I maybe have to do something to
the dates first to get it to compare correctly.

ANy suggestions anyone?

Andrew Hargreaves

>Andrew,
>
[quoted text clipped - 37 lines]
>>Andrew H
>>.
Cindy M  -WordMVP- - 11 Oct 2003 10:31 GMT
> Does Word have a problem with dates in general?

Yes, definitely.

You may want to try including a date-picture switch in the fields (and
leave the term Mergefield in them!) to see if that helps at all. I might
try \@ "yyyy-mm-dd" to achieve the best comparison.

> Sorry to follow this one up so late, but I'm still trying to get it to
> work. At the moment the code I have is as follows:
[quoted text clipped - 16 lines]
> struggling to compare dates, and that I maybe have to do something to
> the dates first to get it to compare correctly.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)
Marty - 08 Dec 2003 15:21 GMT
Andrew,

Did you receive a workable answer to your query "caomparing two dates" ?? If you did can you please share the answer, as i am having to copare two dates and find the same problems that you faced.

Marty
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.