none
Mail merge fields starting with a number RRS feed

  • Question

  • I am creating mail-merge letters in Word 2010, from MS Dynamics CRMv4.0 data, but have reproduced this using data from Excel.

    I use the IF field to obtain customised mail-merge results, and have found an issue with conditions that start with a number.

    For example, if the first address line is “21 Main Street”, write “21 Main Street” else write nothing I wrote:

     

    What I find is that the condition is met for every address starting with “21  “ ( 21 followed by a space) and so “21 Main Street” is printed for all such records.

    It looks like the equals is being processed as a ‘starts with’.

    Has anyone else found this? Is there a workaround?

    Monday, October 3, 2011 8:03 AM

Answers

  • You need to put quotes around the MERGEFIELD in the comparison, i.e.

    A. { IF "{ MERGEFIELD Address1 }" = "21 Main Street" { MERGEFIELD Address1 } "" }

    rather than

    B. { IF { MERGEFIELD Address1 } = "21 Main Street" { MERGEFIELD Address1 } "" }

    The trouble is that Word "coerces" the data depending on what data types it finds on each side of the "=". AFAIK, if it finds anything that looks numeric, it coerces both sides to be numeric, then does a numeric comparison. If you don't quote the field, Word finds the "20", decides that the data is numeric, and coerces both side to be numeric. If you want to check that, notice that 21 Main Street will probably also match "10 11"  and "3*7" in Address1 if you use version B, because Word will do very simple arithmetic on fields it considers to be numeric.



     

    Word "coerces" the data in IF con


    Peter Jamieson
    • Marked as answer by jacquieg Monday, October 10, 2011 1:39 PM
    Sunday, October 9, 2011 11:01 AM

All replies

  • It's not really clear what you want.  Maybe if you provided some more examples of the data in the field and the results that you want for each one it would help.

    But, instead of putting 21 Main Street as the text to be returned, it is probably better to use { MERGEFIELD Address1 } as if

    { IF { MERGEFIELD Address1 } = "21 Main Street" { MERGEFIELD Address1 } "" }


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    Monday, October 3, 2011 8:42 AM
  • You need to put quotes around the MERGEFIELD in the comparison, i.e.

    A. { IF "{ MERGEFIELD Address1 }" = "21 Main Street" { MERGEFIELD Address1 } "" }

    rather than

    B. { IF { MERGEFIELD Address1 } = "21 Main Street" { MERGEFIELD Address1 } "" }

    The trouble is that Word "coerces" the data depending on what data types it finds on each side of the "=". AFAIK, if it finds anything that looks numeric, it coerces both sides to be numeric, then does a numeric comparison. If you don't quote the field, Word finds the "20", decides that the data is numeric, and coerces both side to be numeric. If you want to check that, notice that 21 Main Street will probably also match "10 11"  and "3*7" in Address1 if you use version B, because Word will do very simple arithmetic on fields it considers to be numeric.



     

    Word "coerces" the data in IF con


    Peter Jamieson
    • Marked as answer by jacquieg Monday, October 10, 2011 1:39 PM
    Sunday, October 9, 2011 11:01 AM