View Single Post
  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Database Field SQL Statement

Is this still the only way to work around this issue?

As far as I know, yes. When you merge the results should be correct. I've
never understood the rationale for this behaviour (if it's OK to do the
query when you merge, why not when you preview?)

Also, it appears you can use just about anything in place of the tic mark
but you must use something to enclose the tblAirCard.


For one thing, I am forgetting myself: in Word 2003 you get an OLE DB
connection even where you specify an ODBC DSN in the \c parameter. If you
need to use ODBC, you have to specify a suitable file DSN in the \d
parameter (you can usually spot the difference in the results because ODBC
displays dates as date/times in YYYY-MM-DD hh:mm:ss format). I usually use a
FILEDSN in the \c parameter when I do that, e.g. \c
"FILEDSN=c:\\temp\\verizonaircard.dsn;", but I don't think it's actually
essential.

Other thn that, I have no problem with either [ ] or ` ` surrounding the
table name here (whether it's ODBC or OLE DB). I also don't have trouble
with a MERGEFIELD in the WHERE clause, as long as the clause is
syntactically correct for the type of data I'm comparing (e.g.

WHERE CustomerID = '{ MERGEFIELD CustomerID }'
for a text ID but
WHERE CustomerID = { MERGEFIELD CustomerID }
for a numeric ID.

At the moment I can't spot anything else that would make the thing /not/
work, sorry. The only suggestion I can make is to send me a Word doc. with
the DATBASE field and query you really want and I'll see if I can spot
anything (not easy without the database as well, but perhaps worth a try (or
create a test database and send a working and non-working examples.

Peter Jamieson


"mico" wrote in message
...
Yes, this works:
DATABASE \d "C:\\Temp\\VerizonAirCard.mdb" \c "DSN=MS Access Database;DBQ=
C:\\Temp\\VerizonAirCard.mdb;DefaultDir= C:\\Temp;DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;UID=admin; " \s "SELECT *
FROM [tblAirCard] "

Also, it appears you can use just about anything in place of the tic mark
but you must use something to enclose the tblAirCard.

FWIW, I seem to be able to use Excel as a data source correctly and was
even
able to use a Mergefield in a where clause of the SQL statement. This
brings
up another question. Word does not automatically update the table fields
based upon the next Mergefield record. When I move from one record to the
next I have to press F9 to see the update fields. Below is the work
around
noted in April 2006:
==========================================
OK, I've just checked here. You'll need to add a DWORD value called
FieldCalcSecurityLevel and set the value to 0, under the following
registry
key:
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\W ord\Options
(Follow the instructions for the other versions of Word, but substitute
11.0
in the appropriate place. The instructions are in
http://support.microsoft.com/kb/330079/EN-US/
================================

Is this still the only way to work around this issue?
Thanks again.


"mico" wrote:

OS: XP Pro SP1, Word 2003 SP2

DATABASE \d "C:\\Temp\\VerizonAirCard.mdb" \c "DSN=MS Access
Database;DBQ=
C:\\Temp\\VerizonAirCard.mdb;DefaultDir= C:\\Temp;DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;UID=admin; " \s "SELECT * FROM
'tblAirCard' "

Ive been unable to change the select statement above to work properly.
Ive tried to use tic, backslash and tic and backslash to denote the
columns
names and Ive tried using the tablename.fieldname, tablename!fieldname
and
just the field name by itself and everything generates the generic Word
error
unable to open data source. Any advice is appreciated.