K
Karl E. Peterson
Hi Folks --
My apologies for the crosspost, but this one just seems to need multiple
perspectives. I've googled and googled, but not come up with a "best" way
to do this.
I have an Access 2000 database, and would like to use a subset of one its
queries as a datasource for a Word 2000 mailmerge. I found KB article
Q258512 (http://support.microsoft.com/kb/258512/), and have sort of adopted
it to fit. All but subsetting the embedded query.
I don't really want to parameterize the query directly within Access, as I'd
then need to have dialogs popping from Access, right?
Instead, I'd just like to select those records that meet some user-defined
specification. This is the code I'm using to open the datasource:
.OpenDataSource _
Name:=TheDatabase, _
ConfirmConversions:=False, _
ReadOnly:=False, _
LinkToSource:=True, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:="QUERY qryLabels", _
SQLStatement:="SELECT * FROM qryLabels;", _
SQLStatement1:=""
That works, too! But, what I'd _really_ like to use in that SQLStatement
line is something like this:
"SELECT * FROM qryLabels WHERE (((qryLabels.ListID)=3));"
That, however, causes CPU usage to spike, and no results are ever returned.
BOTTOM LINE: Is there a way to use ADO or DAO directly within Word VBA to
select a recordset and assign that as the datasource for the mailmerge?
(The stored query itself uses several tables and is way, way over the
character limit for the OpenDataSource parameters.) Pointers to good
references also appreciated!
Thanks... Karl
My apologies for the crosspost, but this one just seems to need multiple
perspectives. I've googled and googled, but not come up with a "best" way
to do this.
I have an Access 2000 database, and would like to use a subset of one its
queries as a datasource for a Word 2000 mailmerge. I found KB article
Q258512 (http://support.microsoft.com/kb/258512/), and have sort of adopted
it to fit. All but subsetting the embedded query.
I don't really want to parameterize the query directly within Access, as I'd
then need to have dialogs popping from Access, right?
Instead, I'd just like to select those records that meet some user-defined
specification. This is the code I'm using to open the datasource:
.OpenDataSource _
Name:=TheDatabase, _
ConfirmConversions:=False, _
ReadOnly:=False, _
LinkToSource:=True, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:="QUERY qryLabels", _
SQLStatement:="SELECT * FROM qryLabels;", _
SQLStatement1:=""
That works, too! But, what I'd _really_ like to use in that SQLStatement
line is something like this:
"SELECT * FROM qryLabels WHERE (((qryLabels.ListID)=3));"
That, however, causes CPU usage to spike, and no results are ever returned.
BOTTOM LINE: Is there a way to use ADO or DAO directly within Word VBA to
select a recordset and assign that as the datasource for the mailmerge?
(The stored query itself uses several tables and is way, way over the
character limit for the OpenDataSource parameters.) Pointers to good
references also appreciated!
Thanks... Karl