views:

138

answers:

1

Below is my MERGEFIELD code:

{ IF { MERGEFIELD Subs_State } = "GA" "blah blah" "{ IF { MERGEFIELD CEOrgStates } = "*GA*" "blah blah" ""} "}

I'm pulling records from a MS Access database. My goal is to check whether a record has Subs_State field matching "GA", or the CEOrgStates has the word "GA" (some records have stuff like "|FL|CA|GA|CT|KY|" (no quotes)).

When I merged the docs, Word doesn't seem to be able to match with the wildcards: If I use and compare "*GA" (fields ending with GA), it works; however, the double wildcards "*GA*" don't seem to work at all.

Here are the things I've tried:

  • Have data in lowercase, then compare with lowercase
  • Have data in lowercase, convert to and then compare with uppercase
  • Do the opposite of the above 2 with uppercase data
  • Use “*GA*” and “*ga*” (no pipe)
  • Use different delimiters

Nothing seems to work with the double wildcard matching. What am I doing wrong?

+3  A: 

My initial guess here is that you've enclosed your second IF statement in quotes like "{ IF { MERGEFIELD CEOrgStates } = "GA" "blah blah" ""} " - there is no need to do that. Just make it { IF { MERGEFIELD CEOrgStates } = "GA*" "blah blah" ""}, with the wildcard * following GA. Matching is case-sensitive, so ga* wouldn't work.

Secondly, you may already know this, but for the benefit of other readers of this post, to insert a field (the double brackets { something }), you need to use a keyboard combination - you can't just enter the brackets by hand.

Keyboard shortcuts for fields:

  • F9 - updates all fields
  • Alt+F9 - toggles fields between edit and preview
  • Ctrl+F9 - inserts a field { something } at the cursor location; the something is a field name to be filled in by you. The resulting brackets will be bold. So if you have brackets in your code and they are not bold, that means they were entered by hand.
Otaku