Unable to open datasource

S

Salchow

When trying to run a mailmerge from Access 2003 I keep getting "Unable to
open datasource" error. This used to work for me in pervious versions of
Office, but now there seems to be some kind of locking mechanism that
prevents Word from accessing the database.

Connection String

stConnect = "DSN=MEFDSN;DBQ=" & stDatabasePath & ";DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;"

..OpenDataSource Name:=stDatabasePath, _
ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=False, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
Format:=wdOpenFormatAuto, Connection:=stConnect,
SQLStatement _
:="SELECT * FROM `qryMailMerge` WHERE ProsjektID = " +
stProsjektID, SQLStatement1:=""

The strange part is that it seems to work occasionally, but most of the time
it does not.
 
P

Peter Jamieson

If you're using Word 2003, word opens Access databases using OLEDB by
default. Previously, Word would probably have used ODBC, given that you were
providing a DSN in your connection string. The locking assumptions may be
different (I do not know for sure) and although generally speaking you ought
to be able to specify a particular access mode using OLEDB, as far as I can
tell you can't specify the access mode when Word is connecting to a data
source.

WHat you may have to do is try to use ODBC, and in Word 2003 you need to
provide an additional parameter, something like

Subtype:=wdMailMergeSubtypeWord2000

You may need to do more than that but I'd try that first.
 
R

Ravi

Where do you go to edit the datasource? Can you please
tell me step-by step where to go so I can edit this line
in:
Subtype:=wdMailMergeSubtypeWord2000
to make it DDE instead of OLEDB.

Thanks.
 
P

Peter Jamieson

It isn't clear what you are really trying to do here.

If you are using VBA to open your data source, it should be reasonably
obvious where to put the Subtype:= line - you find the existing
OpenDataSource method call, e.g.

OpenDataSource _
Name:="c:\mydbs\mydb.mdb", _
Connection:="TABLE mytable", _
SQLStatement:="SELECT * FROM [mytable]"

and change it to

OpenDataSource _
Name:="c:\mydbs\mydb.mdb", _
Connection:="TABLE mytable", _
SQLStatement:="SELECT * FROM [mytable]", _
Subtype:=wdMailMergeSubtypeWord2000

If you are not actually using VBA and are just trying to get Word 2002 or
2003 to open a .mdb using DDE, check Word Tools|Options|General|"confirm
conversions at open", then go through the process of connecting to the data
source again. In the Select Data Source dialog box, select the .ndb and
proceed. You should see an additional dialog. Choose the option with DDE in
it.

If the problem is that you are trying to get your Edit Recipients box to let
you edit records in Access, don't bother unless the .mdb is an "Office
Address List" (or is sufficiently similar that ord treats it the same way as
an Office Address List). Word recognises the structure of these databases
and allows editing in Edit Recipients.
 

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