J
jillc
Using Access 2003 the following code used to work. The user would click a
button, Word and then the MailMerge original doc would open, and then the
user would have to select which table in the database held their required
data. The table was created in the code immediately preceding the MailMerge
coding below, and the TableName is stored in the string field strTable.
++++ start of code
Dim objWord As Word.Document
Set objWord = GetObject(gstrMergeDocument_ACTION_PLAN,
"Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource Name:=CurrentDb.Name,
LinkToSource:=True, Connection:="TABLE " & strTableName
objWord.MailMerge.Execute
++++ end of code
This had been working for several months, but now the processing only opens
the Word MailMerge original document, without giving the user the facility to
select the table. Access now gives an error on the CommandButton coding,
number -2147417851
I have amended the coding adding
sqlstatement:="select * from [" & strTableName & "]"
after the Connection parameter. This does what is wanted, filling the doc
with the table information, making it more user friendly (they do not have to
select their table"
Were we just lucky that the original coding worked for that period of time,
or is there something deeper which I need to investigate?
button, Word and then the MailMerge original doc would open, and then the
user would have to select which table in the database held their required
data. The table was created in the code immediately preceding the MailMerge
coding below, and the TableName is stored in the string field strTable.
++++ start of code
Dim objWord As Word.Document
Set objWord = GetObject(gstrMergeDocument_ACTION_PLAN,
"Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource Name:=CurrentDb.Name,
LinkToSource:=True, Connection:="TABLE " & strTableName
objWord.MailMerge.Execute
++++ end of code
This had been working for several months, but now the processing only opens
the Word MailMerge original document, without giving the user the facility to
select the table. Access now gives an error on the CommandButton coding,
number -2147417851
I have amended the coding adding
sqlstatement:="select * from [" & strTableName & "]"
after the Connection parameter. This does what is wanted, filling the doc
with the table information, making it more user friendly (they do not have to
select their table"
Were we just lucky that the original coding worked for that period of time,
or is there something deeper which I need to investigate?