View Single Post
  #14   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Merging Access data into a Word document

I can just about see circumstances in which this might occur, but the case
isn't particularly convincing, which suggests that the explanation is likely
to be staring us in the face :-) I gather you're working at a distance from
the problem so it may be difficult to check stuff and experiment.

It seems to me that whatever may be in the Access file or intermediate file,
Word will only compare correctly with "0" if the YesNo value /it reads/ is
"0", and will only compare correctly with "False" if the values it actually
sees are "False" and "True". Which isn't what you actually say, but I wonder
whether that is actually the case.

As far as I know, if Word is getting its data from a text file, the only way
it would see -1 as "True" is if
a. it's opening the file using OLE DB (i.e. it's Word 2002 or later)
b. there's a SCHEMA.INI file in the same folder as the text file that
specifies that the column has type "Bit". This could well be the case
because when you export from Access, Access does create such entries in a
SCHEMA.INI - at least sometimes. If someone is using an Access module or
macro to export, then it may also specify a particular export layout.

However, the hypothesis also has to explain why you see -1/0 when you have a
data source with 1 record, but True/False when it has many records.
Possibilities include
a. Word is opening the file using OLE DB but only recognises that the
column is "Yes/No" type (and provides True/False instead of -1/0 when there
are more than so many records in the file - perhaps 8 or 25. I don't see
this here.
b. Access sets up a SCHEMA.INI entry when it exports multiple records, but
not a single record. (In fact, Access itself does not appear to make this
distinction, although if the export is being done through code, perhaps
something else is doing something differently. What I see is bizar when
you export manually, if you specify a file extension (e.g. .txt) Access just
exports the data and modifes SCHEMA.INI. If you do not, Access takes you
through the export layout dialog and /does not/ modify SCHEMA.INI)
c. Word tries to connect to the one-row data files using OLE DB (the
defaul) but fails and falls back to using its Text converter. With the
multi-row files, it succeeds. This is an unlikely way around.

Even if the right explanation is in there somewhere, there's the question of
what you do about it and how to find out exactly what's going. What I would
probably prefer to do is avoid the problem altoggether by trying to export
the data using the string values "Y" and "N" instead of numeric/boolean
values. If I had to determine connection method etc., I'd probably use Word
VBA to find the values of ActiveDocument.MailMerge.DataSource.COnnectString,
..QueryString and .Type /after/ the connection had been made.

Best I can right now...

Peter Jamieson
"GaryNSHC" wrote in message
...
Peter,

As far as I know:

I believe it is Word 2000, and again my apologies, there is no comma
between
the values (hangover from coding excel IF statement).

I think the data source is exported as a file (merge.888) which is then
used
to create the merge document. I don't think it is directly linked with
Access.

The values are always -1 or 0 depending on what the source data in access
is, depending on whether I am trying to merge one record or all records. I
have about 15 access fields with "Yes" or "No" answers which are being
merged. The fields indicate what activities the person participates in
within
our organisation.

I'll try quoting the meregfield and see if it makes a difference.

Thanks for trying to sort this out for me.

Regards

Gary

"Peter Jamieson" wrote:

If I have just:
{mergefield MAACTeam} I get either "0" or "-1" depending on whether it
should be "YES" or "NO".


Is this actually -1 for Yes and 0 for No (in which case are you using
Word
2000 or earlier and/or connecting using DDE? AFAIK the values Word
receives
are as follows:

Connection method "Yes" "No"
DDE -1 0
ODBC 0 1
OLE DB True False

When you say "works for a single record" what are you doing differently?
Do
you mean you are connecting to a different data source that only has one
record, are you using the same table/query as the data source in both
merges
and changing the query criteria for one of them? Or what? Also, are the
Yes/No results for just

{ mergefield MAACTeam }

always -1 and 0, or do they actually differ depending on whehter you are
doing 1 record or many records?

Also, are you really using "FALSE" rather than "False"? Can we assume
that
you have not got commas in your IF field? Do you have a bookmark called
False in your Mail Merge Main Document or any included file? Does it make
any difference if you quote the mergefield, e.g.

{ IF "{ MERGEFIELD MAACTeam }" = "0" "No" "Yes" }

Peter Jamieson


"GaryNSHC" wrote in message
...
My apologies, I am using an IF condition as well as a MERGEFIELD.

The one which works in a single record is:
{IF {mergefield MAACTeam} = "0", "No", "Yes"} and I get "NO"
if I change = "0" to either = "TRUE" or = "FALSE" I get "YES" which is
incorrect.

The one which works for all records is:
{IF {mergefield MAACTeam} = "FALSE", "No", "Yes"} I get either "YES"
or
"NO"
if I change = "FALSE" to either = "0" or = "-1" I get "YES" for all
records
which is incorrect.

If I have just:
{mergefield MAACTeam} I get either "0" or "-1" depending on whether it
should be "YES" or "NO".

Hope this clarifies the problem being encountered.

Regards

Gary

"Graham Mayor" wrote:


What exactly does {Mergefield name} produce when inserted without a
condition?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


GaryNSHC wrote:
I am using this piece of code and am having a little problem with my
mergefields not picking up the correct value for a YES/NO field.

If I use {mergefield name ="false" ...} it doesn't work with single
records but does when I use all records.

BUT ..

When I use {mergefield name = "0" ..} it works for single records
but
not for all records.

Whichever way I go, I can't seem to get the word template to pay
ball
correctly whether I use a single record or merge all records.

Has anyone else come across this, and if so, how was it resolved?

Regards

Gary

"Doug Robbins - Word MVP" wrote:

See the "Super Easy Word Merge" item at
http://www.members.shaw.ca/AlbertKal.../msaccess.html

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of
my
services on a paid consulting basis.

Doug Robbins - Word MVP