LarryDeLaruelle
Technical User
I am trying to set up a mail merge function in Access '97 (as described in MS Document Q159328) and it runs OK up to a point:<br><br>a new instance of Access is opened (which is another problem for another day);<br><br>Word opens;<br><br>then I get a run time error (5992) "Word was unable to open the data source".<br><br>Here is the code (pretty much as I picked it up from the MS doc):<br><br>Public Function Mergeit(strOaklawn As String)<br><br>Dim objWord As Word.Document<br>Set objWord = GetObject("C:\WordForms\DisSum.dot", "Word.Document"<br><br>' Make Visible<br>objWord.Application.Visible = True<br><br>' Set the mail merge data source<br>objWord.MailMerge.OpenDataSource _<br>Name:="G:\database\TCC Reports\TCCReports.mdb", _<br>linktosource:=True, _<br>Connection:="QUERY qbeWordForm1", _<br>sqlstatement:="SELECT * FROM [qbeWordForm1] WHERE [OaklawnNum] = '" & strOaklawn & "' ;"<br><br>' Execute the Mail Merge<br>objWord.MailMerge.Execute<br><br>End Function<br><br>I tried the Help button when I got the run time error and was politely informed that the "Topic does not exist".<br><br>When I click on debug, it highlights the entire .OpenDataSource line with the yellow arrow pointing at the last line (the SQL statement).<br><br>My guess is that something is not right with the SQL statement but I am at a loss to figure out just what that might be.<br><br>My undieing gratitude to anyone who can set me on the path to enlightenment.<br><br><br><br>