Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
conditional merge with text comparison?
I am using MS Word 2003. I have a database of member accounts with a 3-
letter field in it, that if it starts with W, it means the person is a woman. I would like to be able to write something special on the women's letters. I thought I could do something such as If Fieldname starts with W, then "text". But I find that the choices are limited to =, not =, greater than, less than, etc. I tried using a wildcard W**, but that didn't work either. Is there a way to do this? Thank you. |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
conditional merge with text comparison?
The wildcar approach should work e.g.
{ IF "{ MERGEFIELD fieldname \*Upper }" = "W*" "woman text" "non-woman text" } But all the {} have to be the special field code braces you can enter using ctrl-F9. FWIW, as a general rule it's better to separate things like this into sepearte columns in your database. For some types of data source, you can do that in a query or view rather than modifying your code structure or duplicating data. For some types of data source, you can also issue a query from Word VBA that will split the datainto two columns. -- Peter Jamieson http://tips.pjmsn.me.uk wrote in message ... I am using MS Word 2003. I have a database of member accounts with a 3- letter field in it, that if it starts with W, it means the person is a woman. I would like to be able to write something special on the women's letters. I thought I could do something such as If Fieldname starts with W, then "text". But I find that the choices are limited to =, not =, greater than, less than, etc. I tried using a wildcard W**, but that didn't work either. Is there a way to do this? Thank you. |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
conditional merge with text comparison?
wildcar-wildcard!
-- Peter Jamieson http://tips.pjmsn.me.uk "Peter Jamieson" wrote in message ... The wildcar approach should work e.g. { IF "{ MERGEFIELD fieldname \*Upper }" = "W*" "woman text" "non-woman text" } But all the {} have to be the special field code braces you can enter using ctrl-F9. FWIW, as a general rule it's better to separate things like this into sepearte columns in your database. For some types of data source, you can do that in a query or view rather than modifying your code structure or duplicating data. For some types of data source, you can also issue a query from Word VBA that will split the datainto two columns. -- Peter Jamieson http://tips.pjmsn.me.uk wrote in message ... I am using MS Word 2003. I have a database of member accounts with a 3- letter field in it, that if it starts with W, it means the person is a woman. I would like to be able to write something special on the women's letters. I thought I could do something such as If Fieldname starts with W, then "text". But I find that the choices are limited to =, not =, greater than, less than, etc. I tried using a wildcard W**, but that didn't work either. Is there a way to do this? Thank you. |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
conditional merge with text comparison?
"Peter Jamieson" wrote in message { IF "{ MERGEFIELD fieldname \*Upper }" = "W*" "woman text" "non-woman text" } Hi Peter - Thanks for your reply. Does that mean you are looking for a field that begins with upper case W followed by other characters? Is it possible to compare against a field that may have a particular word in it and it is not uppercase? Such as you are looking to find occupation fields that contain the word "editors" and in the records are things like "NY writers" "NY editors" NY columnists" "Boston editors" etc. Any way to pull out the editors? thanks for your help! |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
conditional merge with text comparison?
Does that mean you are looking for a
field that begins with upper case W followed by other characters? Yes, but there are limits, e.g. the field probably can't be more than 64 characters or 128 characters - I can never remember which. Is it possible to compare against a field that may have a particular word in it and it is not uppercase? Only if it is at the beginning or end of the field (I notice that's what your examples have). You can use * as a wildcard at the beginning, end or middle of the comparison text, but not at both ends. You can also use ? to compare a single character. However, again as a general rule if you are using a database package such as Access, it's generally easier to do this kind of thing using a query/view, creating new columns that you can then use in Word to do the test you need. e.g. in Access you might have something like SELECT *,iif(instr(mytextfield,"editors",1)0,'Y','N') AS [containseditors] FROM mytable (That precise example isn't tested but if you get around to doing that kind of stuff you can check back if you can't make it work - or ask in a group concerned with the database package you're using). If your database is in Excel you can in effect create a new column that uses an Excel function to do something similar. -- Peter Jamieson http://tips.pjmsn.me.uk wrote in message ... "Peter Jamieson" wrote in message { IF "{ MERGEFIELD fieldname \*Upper }" = "W*" "woman text" "non-woman text" } Hi Peter - Thanks for your reply. Does that mean you are looking for a field that begins with upper case W followed by other characters? Is it possible to compare against a field that may have a particular word in it and it is not uppercase? Such as you are looking to find occupation fields that contain the word "editors" and in the records are things like "NY writers" "NY editors" NY columnists" "Boston editors" etc. Any way to pull out the editors? thanks for your help! |
#6
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
conditional merge with text comparison?
Hi cdsandler,
Actually, Peter's example doesn't care whether the data at the source is upper case or lower. The '\*Upper' switch in the mergefield merely forces the result to come out as upper case for the purposes of testing so that you don't have to test separately for 'W' and 'w'. As for finding 'editors' in a longer string, Word's fields are rather limited. If you know that the string you're looking for is at the start or end of a longer string, you could use "editors*" or "*editors", respectively. However, if 'editors' isn't at the start or end of the string, you have to tell Word how many characters from the end it will be found (if it exists) - you can't use "*editors*". For example, "???editors*" would tell Word that three characters precede 'editors' and any number of characters might follow it. -- Cheers macropod [MVP - Microsoft Word] wrote in message ... "Peter Jamieson" wrote in message { IF "{ MERGEFIELD fieldname \*Upper }" = "W*" "woman text" "non-woman text" } Hi Peter - Thanks for your reply. Does that mean you are looking for a field that begins with upper case W followed by other characters? Is it possible to compare against a field that may have a particular word in it and it is not uppercase? Such as you are looking to find occupation fields that contain the word "editors" and in the records are things like "NY writers" "NY editors" NY columnists" "Boston editors" etc. Any way to pull out the editors? thanks for your help! |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Conditional Text/Mail Merge | Microsoft Word Help | |||
Merge comparison operators missing | Mailmerge | |||
Conditional Currency/Text Field Format in Merge | Mailmerge | |||
using conditional merge, how do I not merge blank records... | Mailmerge | |||
how do i format conditional text in a word mail merge | Mailmerge |