C
cjg.groups
In Access 2003, I am using VB to build a complex MAKE TABLE query,
store it in a new Query Def, then execute it to make the table. I then
launch a Word mail merge using that new table as the data source. The
Word template is not bound to a data source.
When I run the code, Word shows the Data Link window asking for a data
source. Trying to cancel says the data source is already open, but the
merge runs anyway. This happens often, but not always, and I can't
tell what causes it.
Is the complex MAKE TABLE simply not finished creating when the merge
executes? The merge to Word in VB seems so flakey; it works, but often
throws generic errors. Below is a code excerpt. Any ideas? Thanks.
Set qdfMake = db.CreateQueryDef("", strSQL)
qdfMake.Parameters(0) = Eval(strCtlOID)
qdfMake.Execute
appWord.Visible = True
objWord.MailMerge.OpenDataSource Name:="E:\data.mdb",
LinkToSource:=True, Connection:="TABLE tbltempOutputReport",
SQLStatement:="SELECT * FROM [tbltempOutputReport]"
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
store it in a new Query Def, then execute it to make the table. I then
launch a Word mail merge using that new table as the data source. The
Word template is not bound to a data source.
When I run the code, Word shows the Data Link window asking for a data
source. Trying to cancel says the data source is already open, but the
merge runs anyway. This happens often, but not always, and I can't
tell what causes it.
Is the complex MAKE TABLE simply not finished creating when the merge
executes? The merge to Word in VB seems so flakey; it works, but often
throws generic errors. Below is a code excerpt. Any ideas? Thanks.
Set qdfMake = db.CreateQueryDef("", strSQL)
qdfMake.Parameters(0) = Eval(strCtlOID)
qdfMake.Execute
appWord.Visible = True
objWord.MailMerge.OpenDataSource Name:="E:\data.mdb",
LinkToSource:=True, Connection:="TABLE tbltempOutputReport",
SQLStatement:="SELECT * FROM [tbltempOutputReport]"
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute