?
Solved

Word 2007 mail merge not filtering correctly

Posted on 2011-09-29
7
Medium Priority
?
338 Views
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?

Max
0
Comment
Question by:MaxwellTurner
[X]
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
7 Comments
 
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
0
 
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.
0
 
LVL 1

Author Comment

by:MaxwellTurner
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.

Max
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 74

Expert Comment

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

Accepted Solution

by:
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.

http://ittidbit.blogspot.com/2011/08/ms-word-mail-merge-using-ms-access-like.html

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.

Max
0
 
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:
    Instr([YourField],"5l")=0

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

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

;-)

Jeff
0
 
LVL 1

Author Closing Comment

by:MaxwellTurner
ID: 36938206
Kinda figured it out on my own ...
0

Featured Post

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.

Question has a verified solution.

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

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.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

770 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