Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
mergefield if contains
I am trying to do a mail merge where one of my fields may include multiple
data and depending on whether or not it contains particular data I want to enter specific text. My field is AWARD_DESC and within that field you may or may not have Stafford Loan PLUS Loan Unsubsidized Loan. It may contain one, two, three, or none so I can't set it up as if equals. I want to insert text if it has Stafford Loan, insert text if it has PLUS Loan, etc... Is there a way to do that? Thank you, |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
mergefield if contains
"b4nature" wrote:
I am trying to do a mail merge where one of my fields may include multiple data and depending on whether or not it contains particular data I want to enter specific text. My field is AWARD_DESC and within that field you may or may not have Stafford Loan PLUS Loan Unsubsidized Loan. It may contain one, two, three, or none so I can't set it up as if equals. I want to insert text if it has Stafford Loan, insert text if it has PLUS Loan, etc... Is there a way to do that? If I understand correclty, you have a MERGEFIELD that can have one of three values. Elsewhere, you want to display text that will be different depending on that value. You need nested IF fields. Use the following construction where ever you want that variable text (Each pair of {} must be inserted by doing CTRL-F9.): {IF {MERGEFIELD AWARD_DESC} = "Stafford Loan" "This is a Stafford Loan." "{IF {MERGEFIELD AWARD_DESC} = "PLUS Loan" "This is a PLUS loan." "{IF {MERGEFIELD AWARD_DESC} = "Unsubsidized Loan" "This is an Unsubsidized loan." "This is not a standard loan."}"}"} When you are done building the IF field, select the whole thing and to SHIFT-F9 to toggle back to field values instead of Field codes, then do F9 to update it. "This is not a standard loan." will be displayed if the AWARD_DESC MERGEFIELD contains a value that is different from the three preset ones. Basically, to build an IF nested field, you use the logic of the IF field: IF "Some condition" "Do this if TRUE" "Do this if FALSE" For nested IF fields, you just include another full IF field in the FALSE part... The last FALSE part of the the nested IF Fields will be displayed only when all of the preceding TRUE parts are not TRUE. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
mergefield if contains
I am doing someting wrong. Here is my construction
{IF{MERGEFIELD AWARD_DESC} = "Fed Sub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF{MERGEFIELD AWARD_DESC} = "Fed Unsub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF{MERGEFIELD AWARD_DESC} = "Fed PLUS Loan" " Federal PLUS Loans require the submission of a loan request form." ""}"}"} and here are my results {IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed Sub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed Unsub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed PLUS Loan" " Federal PLUS Loans require the submission of a loan request form." ""}"}"} I have definately gone wrong somewhere. "Jean-Guy Marcil" wrote: "b4nature" wrote: I am trying to do a mail merge where one of my fields may include multiple data and depending on whether or not it contains particular data I want to enter specific text. My field is AWARD_DESC and within that field you may or may not have Stafford Loan PLUS Loan Unsubsidized Loan. It may contain one, two, three, or none so I can't set it up as if equals. I want to insert text if it has Stafford Loan, insert text if it has PLUS Loan, etc... Is there a way to do that? If I understand correclty, you have a MERGEFIELD that can have one of three values. Elsewhere, you want to display text that will be different depending on that value. You need nested IF fields. Use the following construction where ever you want that variable text (Each pair of {} must be inserted by doing CTRL-F9.): {IF {MERGEFIELD AWARD_DESC} = "Stafford Loan" "This is a Stafford Loan." "{IF {MERGEFIELD AWARD_DESC} = "PLUS Loan" "This is a PLUS loan." "{IF {MERGEFIELD AWARD_DESC} = "Unsubsidized Loan" "This is an Unsubsidized loan." "This is not a standard loan."}"}"} When you are done building the IF field, select the whole thing and to SHIFT-F9 to toggle back to field values instead of Field codes, then do F9 to update it. "This is not a standard loan." will be displayed if the AWARD_DESC MERGEFIELD contains a value that is different from the three preset ones. Basically, to build an IF nested field, you use the logic of the IF field: IF "Some condition" "Do this if TRUE" "Do this if FALSE" For nested IF fields, you just include another full IF field in the FALSE part... The last FALSE part of the the nested IF Fields will be displayed only when all of the preceding TRUE parts are not TRUE. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
mergefield if contains
In cases where you have either/or situations based on varying data, it works
just as well to use separate fields instead of trying to nest them. Assuming that only one of the fields will give a True result, you'll get only the message in the TrueText for that field. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA "b4nature" wrote in message ... I am doing someting wrong. Here is my construction {IF{MERGEFIELD AWARD_DESC} = "Fed Sub Stafford Loan" "? Federal Stafford loans require the completion of an entrance interview." "{IF{MERGEFIELD AWARD_DESC} = "Fed Unsub Stafford Loan" "? Federal Stafford loans require the completion of an entrance interview." "{IF{MERGEFIELD AWARD_DESC} = "Fed PLUS Loan" "? Federal PLUS Loans require the submission of a loan request form." ""}"}"} and here are my results {IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed Sub Stafford Loan" "? Federal Stafford loans require the completion of an entrance interview." "{IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed Unsub Stafford Loan" "? Federal Stafford loans require the completion of an entrance interview." "{IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed PLUS Loan" "? Federal PLUS Loans require the submission of a loan request form." ""}"}"} I have definately gone wrong somewhere. "Jean-Guy Marcil" wrote: "b4nature" wrote: I am trying to do a mail merge where one of my fields may include multiple data and depending on whether or not it contains particular data I want to enter specific text. My field is AWARD_DESC and within that field you may or may not have Stafford Loan PLUS Loan Unsubsidized Loan. It may contain one, two, three, or none so I can't set it up as if equals. I want to insert text if it has Stafford Loan, insert text if it has PLUS Loan, etc... Is there a way to do that? If I understand correclty, you have a MERGEFIELD that can have one of three values. Elsewhere, you want to display text that will be different depending on that value. You need nested IF fields. Use the following construction where ever you want that variable text (Each pair of {} must be inserted by doing CTRL-F9.): {IF {MERGEFIELD AWARD_DESC} = "Stafford Loan" "This is a Stafford Loan." "{IF {MERGEFIELD AWARD_DESC} = "PLUS Loan" "This is a PLUS loan." "{IF {MERGEFIELD AWARD_DESC} = "Unsubsidized Loan" "This is an Unsubsidized loan." "This is not a standard loan."}"}"} When you are done building the IF field, select the whole thing and to SHIFT-F9 to toggle back to field values instead of Field codes, then do F9 to update it. "This is not a standard loan." will be displayed if the AWARD_DESC MERGEFIELD contains a value that is different from the three preset ones. Basically, to build an IF nested field, you use the logic of the IF field: IF "Some condition" "Do this if TRUE" "Do this if FALSE" For nested IF fields, you just include another full IF field in the FALSE part... The last FALSE part of the the nested IF Fields will be displayed only when all of the preceding TRUE parts are not TRUE. |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
mergefield if contains
"Suzanne S. Barnhill" wrote:
In cases where you have either/or situations based on varying data, it works just as well to use separate fields instead of trying to nest them. Assuming that only one of the fields will give a True result, you'll get only the message in the TrueText for that field. Very true, you can put all the single IF fields next to each other, and only one of them will be true... But keep in mind that in this case, you cannot have an overall False text when all If fields are false... But you may not need this in your case. |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
mergefield if contains
"b4nature" wrote:
I am doing someting wrong. Here is my construction {IF{MERGEFIELD AWARD_DESC} = "Fed Sub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF{MERGEFIELD AWARD_DESC} = "Fed Unsub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF{MERGEFIELD AWARD_DESC} = "Fed PLUS Loan" " Federal PLUS Loans require the submission of a loan request form." ""}"}"} and here are my results {IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed Sub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed Unsub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed PLUS Loan" " Federal PLUS Loans require the submission of a loan request form." ""}"}"} I have definately gone wrong somewhere. Probably! I do not understand how you are getting: IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = There should be only one term next to IF, but you are getting all of them? In any case, I see that you removed the "All False" text that I had posted: "This is not a standard loan." and replaced it with an empty string: "". In that case, as Suzanne suggested in her reply, you do not need nested fields. If your environmnet is such that {MERGEFIELD AWARD_DESC} is necessarily one item from a known finite set of entries, then you can place all the single IF fields next to each other... |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
mergefield if contains
Unfortunately it isn't one item from a set. The AWARD_DESC field could
contain multiple items. And if one of the items is the Subsidized Loan then I need to include text for that item. If it includes the Unsubsidized loan then I need text for that item. Ultimately the field may or may not include the Sub, Unsub, or PLUS but I need text specific to the items it does contain. So in my example the AWARD_DESC field contains 4 items (Sub, Unsub, PLUS, and Need grant) so I need the text for the sub, unsub and plus. But for some students they may just have Sub and PLUS so I would just want text for Sub and Plus. Some may just have PLUS so I would just need the text for PLUS...and so on. So I do think it needs to be an embedded IF, but I can't get it to work as my poor results show! "Jean-Guy Marcil" wrote: "b4nature" wrote: I am doing someting wrong. Here is my construction {IF{MERGEFIELD AWARD_DESC} = "Fed Sub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF{MERGEFIELD AWARD_DESC} = "Fed Unsub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF{MERGEFIELD AWARD_DESC} = "Fed PLUS Loan" " Federal PLUS Loans require the submission of a loan request form." ""}"}"} and here are my results {IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed Sub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed Unsub Stafford Loan" " Federal Stafford loans require the completion of an entrance interview." "{IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = "Fed PLUS Loan" " Federal PLUS Loans require the submission of a loan request form." ""}"}"} I have definately gone wrong somewhere. Probably! I do not understand how you are getting: IF Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant = There should be only one term next to IF, but you are getting all of them? In any case, I see that you removed the "All False" text that I had posted: "This is not a standard loan." and replaced it with an empty string: "". In that case, as Suzanne suggested in her reply, you do not need nested fields. If your environmnet is such that {MERGEFIELD AWARD_DESC} is necessarily one item from a known finite set of entries, then you can place all the single IF fields next to each other... |
#8
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
mergefield if contains
"b4nature" wrote:
Unfortunately it isn't one item from a set. The AWARD_DESC field could contain multiple items. And if one of the items is the Subsidized Loan then I need to include text for that item. If it includes the Unsubsidized loan then I need text for that item. Ultimately the field may or may not include the Sub, Unsub, or PLUS but I need text specific to the items it does contain. So in my example the AWARD_DESC field contains 4 items (Sub, Unsub, PLUS, and Need grant) so I need the text for the sub, unsub and plus. But for some students they may just have Sub and PLUS so I would just want text for Sub and Plus. Some may just have PLUS so I would just need the text for PLUS...and so on. So I do think it needs to be an embedded IF, but I can't get it to work as my poor results show! You only need the nested fields if you need an overall False stement (When all conditions are not true). Now, I think you need to take as step back an describe your document in more details. As far as I know, a MERGEFIELD can only contain one item, but you seem to be stating that in your case it may contain more than one (You wrote: "The AWARD_DESC field could contain multiple items" ???). How is AWARD_DESC populated? Are we really talking about a mail merge here? If so, where is the data from? How is it obtained? |
#9
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
mergefield if contains
Thank you for your patience. Ultimately I am trying to merge from a word
doument that has the fields and data generated from our school's software. So I am merging from a word document that looks like this: STUD_ID "123-45-6789" AIDY_YR_DESC., "2008-2009 Academic Year." AID_YEAR, "0809", AWARD_DESC, "Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant", BUDGET_DESCRIPTION, "Undergrad/Resident/Off Campus.", STUD_ID "234-56-7890" AIDY_YR_DESC., "2008-2009 Academic Year." AID_YEAR, "0809", AWARD_DESC, "Fed Sub Stafford Loan Fed PLUS Loan BUDGET_DESCRIPTION, "Undergrad/Resident/Off Campus.", Every student has a record and the AWARD_DESC can be different for every student. When I merge into a letter, for the first student here, I want to include the text for sub, unsub and plus. For the second student I would want just the sub and plus. Does that make any sense? "Jean-Guy Marcil" wrote: "b4nature" wrote: Unfortunately it isn't one item from a set. The AWARD_DESC field could contain multiple items. And if one of the items is the Subsidized Loan then I need to include text for that item. If it includes the Unsubsidized loan then I need text for that item. Ultimately the field may or may not include the Sub, Unsub, or PLUS but I need text specific to the items it does contain. So in my example the AWARD_DESC field contains 4 items (Sub, Unsub, PLUS, and Need grant) so I need the text for the sub, unsub and plus. But for some students they may just have Sub and PLUS so I would just want text for Sub and Plus. Some may just have PLUS so I would just need the text for PLUS...and so on. So I do think it needs to be an embedded IF, but I can't get it to work as my poor results show! You only need the nested fields if you need an overall False stement (When all conditions are not true). Now, I think you need to take as step back an describe your document in more details. As far as I know, a MERGEFIELD can only contain one item, but you seem to be stating that in your case it may contain more than one (You wrote: "The AWARD_DESC field could contain multiple items" ???). How is AWARD_DESC populated? Are we really talking about a mail merge here? If so, where is the data from? How is it obtained? |
#10
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
mergefield if contains
"b4nature" wrote:
Thank you for your patience. Ultimately I am trying to merge from a word doument that has the fields and data generated from our school's software. So I am merging from a word document that looks like this: STUD_ID "123-45-6789" AIDY_YR_DESC., "2008-2009 Academic Year." AID_YEAR, "0809", AWARD_DESC, "Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant", BUDGET_DESCRIPTION, "Undergrad/Resident/Off Campus.", STUD_ID "234-56-7890" AIDY_YR_DESC., "2008-2009 Academic Year." AID_YEAR, "0809", AWARD_DESC, "Fed Sub Stafford Loan Fed PLUS Loan BUDGET_DESCRIPTION, "Undergrad/Resident/Off Campus.", Every student has a record and the AWARD_DESC can be different for every student. When I merge into a letter, for the first student here, I want to include the text for sub, unsub and plus. For the second student I would want just the sub and plus. Does that make any sense? Now it does! Unfortunately, especially since it is almost "going home time" on Friday... I can't find an easy way to do this. If you have four types of AWARD_DESC, then you have at least 16 different combination... I guess you could write 15 IF fields ({IF AWARD = Sub...Unsub... PLUS "3 texts" ""}, {IF AWARD = Unsub... PLUS "2 texts" ""}, etc.) (You do not need a field for the 16th possibility which is no AWARD at all.) Lots of work! Ideally, the database would need to be re-organized to create 4 fields: AWARD_DESC_1, AWARD_DESC_2, AWARD_DESC_3 and AWARD_DESC_4. It was a bad idea to have such a multiple field... Not just for you, but what if the school needed statistics on awards... Good luck! I hope somebody else comes along with a brilliant idea! |
#11
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
mergefield if contains
Thanks for your help. Maybe I can convince my higher ups to do some
re-organizing! "Jean-Guy Marcil" wrote: "b4nature" wrote: Thank you for your patience. Ultimately I am trying to merge from a word doument that has the fields and data generated from our school's software. So I am merging from a word document that looks like this: STUD_ID "123-45-6789" AIDY_YR_DESC., "2008-2009 Academic Year." AID_YEAR, "0809", AWARD_DESC, "Fed Sub Stafford Loan Fed Unsub Stafford Loan Fed PLUS Loan UNC Need Based Grant", BUDGET_DESCRIPTION, "Undergrad/Resident/Off Campus.", STUD_ID "234-56-7890" AIDY_YR_DESC., "2008-2009 Academic Year." AID_YEAR, "0809", AWARD_DESC, "Fed Sub Stafford Loan Fed PLUS Loan BUDGET_DESCRIPTION, "Undergrad/Resident/Off Campus.", Every student has a record and the AWARD_DESC can be different for every student. When I merge into a letter, for the first student here, I want to include the text for sub, unsub and plus. For the second student I would want just the sub and plus. Does that make any sense? Now it does! Unfortunately, especially since it is almost "going home time" on Friday... I can't find an easy way to do this. If you have four types of AWARD_DESC, then you have at least 16 different combination... I guess you could write 15 IF fields ({IF AWARD = Sub...Unsub... PLUS "3 texts" ""}, {IF AWARD = Unsub... PLUS "2 texts" ""}, etc.) (You do not need a field for the 16th possibility which is no AWARD at all.) Lots of work! Ideally, the database would need to be re-organized to create 4 fields: AWARD_DESC_1, AWARD_DESC_2, AWARD_DESC_3 and AWARD_DESC_4. It was a bad idea to have such a multiple field... Not just for you, but what if the school needed statistics on awards... Good luck! I hope somebody else comes along with a brilliant idea! |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Mergefield | Microsoft Word Help | |||
MergeField | Mailmerge | |||
Using IF with MERGEFIELD | Mailmerge | |||
OR in a mergefield? | Mailmerge | |||
MERGEFIELD error | Page Layout |