> 1. TWO additional instances of the database are being opened during the
> mailmerge process.
As a first shot, some guesses....
If the document you are opening from Access has been saved as a mail merge
main document with an Access data source, Word will probably try to open
that data source when it opens the document, and in those circumstances it
may create another instance of Access - almost certainly so if the database
is different from the one you have open already.
If the document you are opening is actually a template and Word actually
tries to create a new document based on the template, both the template and
the new document have a data source attached, so Word will try to open the
data source twice.
However, even if either of those things is true, it does not really explain
why Word would open another instance when you already have the database
open. The following articles might provide a clue:
http://support.microsoft.com/default.aspx?scid=kb;en-us;224697
http://support.microsoft.com/default.aspx?scid=kb;en-us;199963
Although the first article says it applies to Word 97 and that the problem
was corrected in Word 2000, I have a suspicion that a similar problem with
DDE may be occuring, but for slightly different reasons than are mentioned
in the article. One possibility is that if the full path name of your .mdb
is long or contains space characters etc., DDE may not match the database
name correctly and may try to open another instance. Another possibility is
that if you have a window such as a table design window open in Access
(quite likely when you're developing/debugging etc.) DDE may try to open
another instance. I don't think it does - I think it simply fails - but it's
worth checking.
Ignore the ODBC workaround in these articles - it does not work with Access
queries that use user-defined functions such as myrow().
> Need help to stop the extra instances of Access loading up. I've got to
> implement this in an office system - I can't have that happening.
Yes, unfortunately the way Word and DDE work together make it very difficult
to control this. Using ODBC to connect avoids opening any instances of
Access, but then you have to consider the following:
a. does ODBC work when when the database is already open?
b. if the database is protected (either with a database password or with
user-level/workgroup security) you may not be able to access it with ODBC
despite the fact that it is already open (in fact I think you are more
likely to be able to do this with workgroup security than a
password-protected database)
c. you won't be able to use user-defined functions to specify the rows you
want, so you have to use a different approach. That obviously depends on
what you are attempting, but some possibilities are:
- use Access to flag the records you need (or the ones you don't) and
construct a query that relies on selecting flagged/unflagged records. Not
usually a good approach in my experience.
- use Access to create a table with one record for each row you want to
include, and construct a query that uses that info to extract the records
you need. May be OK if only one user accesses the database at a time.
- use code to generate the precise query you need and either
- use that to create a query in Access, then use that as the data
source (never tried it) or
- issue that query in your Word OpenDataSource.
In both cases you would probably face limitations in terms of query
length and probably complexity (e.g. there could be a limit on the number of
ORs in a WHERE clause). A spcific limitation is that OpenDataSource cannot
issue a query longer than either around 256 chars. or 512 chars.
Best I can do for now,
Peter Jamieson
> aha
> ...I've tried changing the SQL statement to: SQLStatement:="SELECT * FROM
[quoted text clipped - 254 lines]
>> >> >> >
>> >> >> > Is there a workaround?