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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wildcards in Word Field Codes Not Working!

Status
Not open for further replies.

dd2008

Programmer
Sep 3, 2008
2
US
I haven't been able to find any information on this at all:

For some reason, when I use wildcards in an if statement for a fieldcode, only some of them work. Lets say I'm trying to find anything with F0 in it.

Ex:
*F0 - works
F0* - works
*F0* - Doesn't work!

Anyone know the reason? Actual if statement is posted below:

Code:
{IF{MERGEFIELD CODE}="F0" "yes" "{IF{MERGEFIELD CODE}="F0*" "yes" "{IF{MERGEFIELD CODE}="*F0*" "yes" "{IF{MERGEFIELD CODE}="*F0" "yes" "no"}"}"}"}

I switched the location of the *F0* statement with *F0, and it still didn't work, so I'm thinking it has to be a wildcard issue.

 
Hi dd2008,

*F0 - works if the string ends in F0
F0* - works if the string starts with F0
*F0* - doesn't work.

If you know eaxctly how far from either end of the string the 'F0' appears, you can use coding along the lines of:
*F0???
or:
???F0*
where the number of ?s equals the number of preceding/trailing characters. Thus, yor field construction would become something like:
Code:
{IF{MERGEFIELD CODE}= "???F0*" "true text" "false text"}
You could extend this to test of a number of possible positions from either end but, if the position of the 'F0' in the string varies greatly, you'll need to do the testing at the data source and add another field to hold the result of that test.

Cheers

[MS MVP - Word]
 
Hey macropod:

Thanks for the tip. Unfortunately, it does vary greatly, and I do not have control of what is put into the datasource. I wonder why Microsoft would allow wildcards, but not both?

It seems pretty odd to me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top