OpenDataSource still asks for a table name

  • Thread starter Don Petersen via OfficeKB.com
  • Start date
D

Don Petersen via OfficeKB.com

I'm updating an application from 2000 to 2003. I've read that 2003 doesn't
use DDE. Upon Microsoft's suggestion in a knowledge article I tried both
SQLStatement:="QUERY Select * From Docs;"
and
Connection:="TABLE [Docs]", _
SubType:=wdMergeSubTypeWord2000
as clauses in my OpenDataSource. Neither had any impact. I was still
prompted for a table name.
Any suggestions?
Thanks
 
P

Peter Jamieson

Word 2003 /can/ use DDE but it now uses OLEDB by default.

Assuming you are connecting to Access, for DDE you will probably need:

yourMailMergeObject.OpenDataSource _
Name:="the full pathname of your .mdb", _
Connection:="TABLE Docs", _
SQlStatement:="SELECT * FROM Docs", _
SubType:=wdMergeSubTypeWord2000

In this case you can probably get away with either

yourMailMergeObject.OpenDataSource _
Name:="the full pathname of your .mdb", _
SQlStatement:="SELECT * FROM Docs", _
SubType:=wdMergeSubTypeWord2000

or

yourMailMergeObject.OpenDataSource _
Name:="the full pathname of your .mdb", _
Connection:="TABLE Docs", _
SubType:=wdMergeSubTypeWord2000

As far as I know, you only need the [] around the table name if it contains
characters such as spaces, but it is probably sensible to put them in.

Peter Jamieson
 
D

Don Petersen via OfficeKB.com

I would prefer to not use DDE. However, I tried both solutions, as I tried
to indicate in my first post.
This was to accommodate the new linkage:
doc.MailMerge.OpenDataSource _
Name:=Path & "IPdb.mdb", _
ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
SQLStatement:="QUERY Select * From [Docs];"

and this was to use compatibility mode:
doc.MailMerge.OpenDataSource _
Name:=Path & "IPdb.mdb", _
ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="TABLE [Docs]", _
SubType:=wdMergeSubTypeWord2000

I even tried putting both clauses into compatibility mode:
doc.MailMerge.OpenDataSource _
Name:=Path & "IPdb.mdb", _
ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="TABLE [Docs]", _
SQLStatement:="QUERY Select * From [Docs];", _
SubType:=wdMergeSubTypeWord2000

I'm still getting prompted for a table.
 
P

Peter Jamieson

You (still) need to eliminate the word "QUERY" from your SQLStatement. For
OLEDB,

doc.MailMerge.OpenDataSource _
Name:=Path & "IPdb.mdb", _
SQLStatement:="Select * From [Docs];"

should be enough, and you do need the [] in this case.

Peter Jamieson
 
D

Don Petersen via OfficeKB.com

I've tried about every syntactic variation on the SQLStatement clause. Some
result in a run-time error. Some result in a prompt for a table name. None
result in the datasource being opened and automagically pointing to the
proper table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top