Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] spy_234432@yahoo.com is offline
external usenet poster
 
Posts: 1
Default Unable to open data source

This is not a mailmerge question, but I thought that someone might be
able to help since I have seen similar questions here. I am trying to
pull information out of an Access database into my word doc.

This won't work

{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select Priority from
\"case_summary_table\" }

But this will

{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select * from \"case_summary_table
\" }

The difference in the second one is that I am querying all of the
fields in the table.

Thanks in advance for your help.

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Unable to open data source

The syntax rules for Jet queries (whether you're connecting via DATABASE or
as a merge data source) are not at all clear - i.e. I have no idea why the
\" \" quoting syntax works when you use * but not otherwise.

However, my general experience so far is that
a. syntax using double-quotes seems to be a relatively recent innovation,
and it does not always seem to work as you might hope. The fact that the
double-quotes have to be quoted using \ in fields may also be a factor.
b. in this case any of the following would probably work:
no quotes (but you would need /some/ quoting if the table name contained
spaces:
{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select Priority from
case_summary_table }
square brackets (Jet syntax AFAIK):
{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select [Priority] from
[case_summary_table] }
back quotes (older? Jet syntax)
{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select `Priority` from
`case_summary_table` }

Since the square brackets approach seems to work in most cases, I'd stick
with that. However, if you were connecting via OLE DB rather than ODBC you
might find that you also had to create and use a table alias.

Peter Jamieson

wrote in message
oups.com...
This is not a mailmerge question, but I thought that someone might be
able to help since I have seen similar questions here. I am trying to
pull information out of an Access database into my word doc.

This won't work

{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select Priority from
\"case_summary_table\" }

But this will

{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select * from \"case_summary_table
\" }

The difference in the second one is that I am querying all of the
fields in the table.

Thanks in advance for your help.



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Unable to open data source

BTW as far as I can tell, Word 2003 never uses ODBC directly to get data
from Access when it executes a DATABASE field. I suspect, but am not
completely sure, that it uses the OLE DB Provider for ODBC Drivers to do it.
The sreason I suspect that is because when you use OLE DB to open an Access
Mailmerge data source, Access YesNo field values come through as "True" and
"False". With ODBC the values are 1 and 0. If you set up a .odc that uses
the OLEDB Provider for ODBC Drivers, you see True and False (which I think
means that the result set is treeated differently by Word, or perhaps some
automatic formatting is done in the Provider). When you use a DATABASE
field, the values always appear to be True and False, never 1 and 0.

If you're trying to maintain maximum compatibility between versions of Word,
then using the ODBC approach is probably going to work as well as anything
(bearing in mind that the results may be formatted differently in different
versions of Word). Otherwise, you might be better off leaving out the
connection string altogether (unless you have to specify something in it,
such as a system/workgroup database) and just specifying the .mdb. Word
should then use OLE DB to open it.

Peter Jamieson

"Peter Jamieson" wrote in message
...
The syntax rules for Jet queries (whether you're connecting via DATABASE
or as a merge data source) are not at all clear - i.e. I have no idea why
the \" \" quoting syntax works when you use * but not otherwise.

However, my general experience so far is that
a. syntax using double-quotes seems to be a relatively recent innovation,
and it does not always seem to work as you might hope. The fact that the
double-quotes have to be quoted using \ in fields may also be a factor.
b. in this case any of the following would probably work:
no quotes (but you would need /some/ quoting if the table name contained
spaces:
{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select Priority from
case_summary_table }
square brackets (Jet syntax AFAIK):
{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select [Priority] from
[case_summary_table] }
back quotes (older? Jet syntax)
{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select `Priority` from
`case_summary_table` }

Since the square brackets approach seems to work in most cases, I'd stick
with that. However, if you were connecting via OLE DB rather than ODBC you
might find that you also had to create and use a table alias.

Peter Jamieson

wrote in message
oups.com...
This is not a mailmerge question, but I thought that someone might be
able to help since I have seen similar questions here. I am trying to
pull information out of an Access database into my word doc.

This won't work

{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select Priority from
\"case_summary_table\" }

But this will

{ DATABASE \d "C:\\mckdata\\June2006.mdb" \c "DSN=MS Access Database;
DBQ=C:\\mckdata\\June2006.mdb" \s "select * from \"case_summary_table
\" }

The difference in the second one is that I am querying all of the
fields in the table.

Thanks in advance for your help.





Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
trouble with mail merge, word was unable to open data source edie Mailmerge 2 May 10th 06 04:46 PM
Word was unable to open the data source. Michael Suttkus, II Mailmerge 3 November 16th 05 02:29 PM
Unable to open excel data source for word mail merge Trisha Microsoft Word Help 0 October 18th 05 10:59 AM
Unable to change data source [email protected] Mailmerge 0 October 12th 05 06:02 PM
"Word was unable to open the Excel data source" Asp.net Mailmerge Shalini Mailmerge 8 June 23rd 05 02:09 AM


All times are GMT +1. The time now is 04:50 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"