View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Binary Operation in INCLUDEPICTURE Field

1. Generally speaking, Word needs to use { = } fields to do calculations
etc.

2. Word's { = } field does not have bitwise operators AFAIK

3. You could try something like

{ INCLUDEPICTURE "{ IF { = mod(round({ MergeField Image }/4,0),2) } = 1
"C:\\pics\\{MergeField ID}-4.jpg" "C:\\pics\\blank.jpg"}" }

(sorry if my arithmetic is wrong, but you get the idea).

4. If you are in a position to create queries in your Access database,
it might be simpler to do the "and 4" operation in a query, either to
return (e.g.) 0 or 1, or to return the complete pathname as an
additional field, then use that query as the data source for your merge.


--
Peter Jamieson

http://tips.pjmsn.me.uk

Chris wrote:
Hello,

I'm trying to initiate a Mail Merge in Word 2007 from an Access 2007
database. In this database, there is an Image column which is actually just
an integer. I'm using it as a Flag to indicate which of the 8 images are
actually stored for a particular record. The path creation is rather simple,
Static_Path\ID-Flag_Bit.jpg.
So, in access, I would normally do something like
If Me!Image And 4 Then
//This image slot is being used
End if

This has worked well for Access. It's efficient and matches the project's
objectives exactly.
Unfortunately, I can't seem to get it to work in the Mail Merge process.

I've tried the following with no success:

{INCLUDEPICTURE "{IF {MergeField Image} And 4 "C:\\pics\\{MergeField
ID}-4.jpg" "C:\\pics\\blank.jpg"}" }

The error i receive is:
"A field calculation error occured in record 1."

And the field now reads
{ INCLUDEPICTURE "Error! Unknown op code for conditional." }

To make sure it wasn't just me misunderstanding, I changed And to =, and the
picture merged fine. This leads me to believe the And is the problem.

So, is there some special trick to getting bitwise operations working with
mail merge?

Thanks for the help,
Chris