Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word 2010 Is it possible to format MERGEFIELD text based on comparison with another MERGEFIELD? 2

Status
Not open for further replies.

PWD

Technical User
Jul 12, 2002
823
GB
Yes, it is possible to ask a stupid question; here goes. I have set up the following MERGEFIELD that will put in either the appointment date, if it exists in the Access database, or "Unknown"

1st Appt booked - {IF{MERGEFIELD N2_9_FIRST_SEEN_DATE <> "" "{MERGEFIELD N2_9_FIRST_SEEN_DATE \@ "dd/MM/yyyy"}"Unknown"}

This has saved me a lot of time but it would be awesome if I could underline the date if it were after the target date, (another MERGEFIELD).

Thinking about it, would I be able to use another comparison and then set another text switch? "\* Charformat"

Unfortunately, now I can't see anything "out there" other than formatting dats or currency.

Many thanks,
D€$
 
You could use a field coded as:
{IF{MERGEFIELD N2_9_FIRST_SEEN_DATE}<> "" {IF{MERGEFIELD N2_9_FIRST_SEEN_DATE \@ YYYYMMDD}>{MERGEFIELD TARGET_DATE \@ YYYYMMDD} {MERGEFIELD N2_9_FIRST_SEEN_DATE \@ "DD/MM/YYYY" \* Charformat} {MERGEFIELD N2_9_FIRST_SEEN_DATE \@ "DD/MM/YYYY"}} "Unknown"}

Cheers
Paul Edstein
[MS MVP - Word]
 
Hi Paul, I reckoned it would be just about that - thanx, but it's the "\* Charformat" bit that I can't find reference to anywhere in order to make it underlined. Any ideas?

Many thanks,
D€$
 
Hi PWD,

If you look at the field code representation I posted, you'll see that the M of 'MERGEFIELD' in:
{MERGEFIELD N2_9_FIRST_SEEN_DATE \@ "DD/MM/YYYY" \* Charformat}
is underlined.

Cheers
Paul Edstein
[MS MVP - Word]
 
How arcane! Wow Paul!

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
My bad, actually. The Charformat switch won't work with a date picture switch. Consequently, the whole field would have to be underlined, as in:
{IF{MERGEFIELD N2_9_FIRST_SEEN_DATE}<> "" {IF{MERGEFIELD N2_9_FIRST_SEEN_DATE \@ YYYYMMDD}>{MERGEFIELD TARGET_DATE \@ YYYYMMDD} {MERGEFIELD N2_9_FIRST_SEEN_DATE \@ "DD/MM/YYYY"} {MERGEFIELD N2_9_FIRST_SEEN_DATE \@ "DD/MM/YYYY"}} "Unknown"}


Cheers
Paul Edstein
[MS MVP - Word]
 
Wow, mucho respec' :) For some reason I have wrapped from after <> "" to before "Unknown" in quote marks but had omitted the trailing quote mark in my post as I'd had to type it as I couldn't find a way to paste the code and not the result! So I've left them in my revised code and it hasn't fallen over. Unfortunately I don't have any records at the moment that pass the test but I'll sure be keeping my eyes open each time I run a bunch of letters.

Many thanks,
D€$

P.S. I've decided to throw in Italic into this mix too, just for nothing!
 
For a macro to convert text representations of field constructions such as I posted here to working field codes, see Convert Text Representations of Fields to Working Fields in my Mailmerge Tips and Tricks threads at:
&:
There's a lot of other stuff there you might find useful, too.

Cheers
Paul Edstein
[MS MVP - Word]
 
Yes Boys!" Just had a couple of sheets where the date was past the target date and they are what I expected !!!! As you say Skip, arcane! But now know to many [smarty]

Many thanks,
D€$
 
Update: It seems the \* Charformat switch doesn't work at all on systems with Office set up for use with a RTL keyboard - even if it's not enabled. That's what I had and, now that I've removed the offending setting, everything is back to normal and the field code in post of 23 Aug 2017 works fine.

Cheers
Paul Edstein
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top