Word 2007 mail merge not filtering correctly

Posted on 2011-09-29
Last Modified: 2012-05-12
I have several mail merge documents (Word 2007) that use an Access 2007 query as the datasource.  The Access query is filtered with criteria entered for some columns ... however, when I open the Word mail merge document, it retrieves ALL records and seems to ignore the criteria filters I have in the query ??!!  I am aware I can filter within the Word document itself, but I prefer not to do that to keep the merges user-friendly for the users.

Does anyone know why the filtering criteria works at the query level, but not in the mail merge documents?

Question by:MaxwellTurner
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36817415
Sounds odd.

Make *Sure* the mail merge source is indeed to query you want. (Not a table, or some other query)

Then run the query by itself and verify that it is filtering correctly
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36817536
<The Access query is filtered with criteria entered for some columns>
How exactly?
In the SQL itself, of by some selections that the user makes...?

In other words, make sure the Filters are being applied.
If you are selecting the criteria from a form, make sure the form is open and the selections are made, and the filters are being applied.

Author Comment

ID: 36817794
This is odd indeed ... triple confirmed the document was linked to the corrrect query ... all criteria is within the query (no forms).  To make it stranger, I have criteria in several columns, but just ONE column is not filtering properly at the merge document level.  Must be a syntax issue that Access and Word are not completely compatible ... ??  I've certainly encountered much of this with Access vs. SQL Server syntax.

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36817926
Then post the SQL for the query please

Accepted Solution

MaxwellTurner earned 0 total points
ID: 36818210
It is a basic SELECT-FROM-WHERE query.  The only part of the WHERE claus that is ignored by Word is:

Not Like "*5l*" And Not Like "*6l*" And Not Like "1*" And Not Like "*lj 1*" And Not Like "*lj1*"

... and upon closer inspection, it is the only column that is filtered using LIKE.  I found this on google, which confirms there is an issue using the like condition in a query that is used in a mail merge.

I don't like the DNS solution (unless I can use DSN-less connection with Word?)  This Dbase is maintained each night, so I think my best option is to create an additional 'flag' column in my table, and update it to YES or NO based on the above like condition, then use the flag column to filter the merge query.

LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36824409
Yeah, wild cards use a lot of processing because they must check all the possibilities.

Also try using Instr()

something like this perhaps:

This translates into: [YourField] does not contain "5l"

...but your "Flag" column sounds like a good option as well.



Author Closing Comment

ID: 36938206
Kinda figured it out on my own ...

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question