View Single Post
  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default Creating a Directory

OK, for the benefit of other readers, the problem appears to be to do with
the SQL that Word generates when the user specifies merge criteria.

With Word 2003 (possibly also 2002) and a using a Word document as a data
source (possibly also other types of data source)...
If the user goes into Mail Merge Recipients, clicks one of the column
headings, chooses "Advanced" to go into the Query Options dialog, and enters
(say)

myfield greater than or equal to 5

Word generates

SELECT * FROM datasource.doc WHERE (( myfield = '5' ))

i.e. it is doing a text comparison, so if myfield is '11', the record will
be excluded. The SQL should be

SELECT * FROM datasource.doc WHERE (( myfield = 5 ))

However, it's slightly more complicated than that because Word gets the SQL
right the first time you specify the condition, but not when you specify the
condition immediately after you have just merged. i.e., merge, switch back
to the main document, go and set the criterion, Word gets it wrong. But go
and set the criterion again before you merge, and Word gets it right again.

Incidentally, this occurs whether you go into the Query Options dialog from
Mail merge Recipients or from the old Mail Merge Helper.

Peter Jamieson

"Louise" wrote in message
news
The e-mail is on its way to you.

Thanks again.
Louise

"Peter Jamieson" wrote:

try
"Louise" wrote in message
...
Peter

That would be great. (I can't find your e-mail address for me to
de-spam??)

"Peter Jamieson" wrote:

The problem is, I am an IT Trainer and am showing this particular
subject
to
a group of people and we all experienced the same problem. Not very
good!!

Always a problem!

I have tried to replicate this on Word 2003/Win XP, but have not been
able
to get Word to fail so far. However, my sample data is very simple and
may
be too simple - if you can Despam my e-mail address and send me
a. the data file
b. the mail merge main document
c. some hints about the criteria you are using and how you are
setting
them
up (In the advanced options?)
it may help. (But NB, I'll be offline for a few days soon).

Peter Jamieson


"Louise" wrote in message
...
Peter

a. Word XP and Word 2003 (tried it on various PC's)
b. Yes, the first document is the data source, this contains the
names,
addresses etc.
c. Yes
d. No, it doesn't make any difference which order the reports are
created
in. It's always the first one that works.
e. No I haven't tried this but will give it a go.

The problem is, I am an IT Trainer and am showing this particular
subject
to
a group of people and we all experienced the same problem. Not very
good!!

THank you very much.

Louise

"Peter Jamieson" wrote:

A few questions/clarification requests:
a. Which version of Word?
b. Your second document uses the first document as its data
source?
(I
just
want to be sure I understood)
c. You are setting some criteria in the second document to select
the
staff
who've been there for 6 years or more, then merging to a new
directory,
then
changing the criteria to 3 years or less, doing another merge, then
changing
the criteria and merging again, etc.?

if so,
d. does it make any difference which sequence you do the reports
(i.e.
it
is always the first one that works?)
e. if you save close the mail merge main document without saving
after
merge, then open it again and apply the criteria for the next
merge,
then
merge, does that work as it should?

(I haven't tried to replicate this yet, but if (e) works at least
it
gets
you a bit further)

Peter Jamieson

"Louise" wrote in message
...
Hi all

I have a document created in word consisting of staff names,
addresses
and
their years' service.

I have created another document in Word and am using mail merge
to
create
a
Directory, containing those staff who have worked for the Company
for 6
years
or more, 3 or less etc.

The first Directory seems to work ok, however, every directory
after
that
returns everybody instead of the filtered list i have asked for.

Any idea what's gone wrong? Directories never seem to work
properly.

Thank you.

Louise