Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2008
    Location
    All over, Now in Missouri
    Posts
    73

    Unanswered: Mail Merge not working

    I set up a table for data and merged it to the word document. I click on the word doc (in explorer) and it fills the data from the table perfectly. I open the doc from Access and the data is not being merged. Here is what I got from my code in VBA Access:

    ' Clear the table of all records
    DoCmd.OpenQuery "qryStudentDisenrolled_del_temp"

    'Append the record that I need a letter done on
    DoCmd.OpenQuery "qryStudentDisenrolled_append"

    'Open the word doc (Problem: data in table is not in document )
    LWordDoc = "T:\Documents\memoDisenroll.docx"
    Set oApp = CreateObject(Class:="Word.Application")
    oApp.visible = True
    oApp.Documents.Open FileName:=LWordDoc

    I know the problem is Word is not running the query to get data from Access. What should I do?

    Peter
    We tend to look at Linear paths which can lead us to a path of resistance!

  2. #2
    Join Date
    Oct 2009
    Posts
    340
    haven't done what you are doing; but am fairly sure that Word does not run a query when Word doc is opened - it just links to the query record set that is available.

    experiment - but you might actually have to close that query before opening the word doc as a method of saving it..... I know that if I have a Word doc open - and change the query that the Word doc merge will not have the new record set until that query is saved and Word reopened... and since the query does not have to be open for the word merge to use...perhaps just open it like you have , then close it, then open the word doc.....would be interested to hear if this works....

  3. #3
    Join Date
    Apr 2008
    Location
    All over, Now in Missouri
    Posts
    73
    When I click the word doc (Access not opend) it tells me that a query is running (select * from [mydb]). So I am thinking that for some reason the word doc is not running the query when Access opens it. humm

    Peter
    We tend to look at Linear paths which can lead us to a path of resistance!

  4. #4
    Join Date
    Oct 2009
    Posts
    340
    I just opened a Word doc manually that is a Word merge document I use frequently...the last time I opened the query which is its data source was a week past and I did not open Access at all.

    During open it first opened a dialog box "Opening this document will run the following SQL command "Select * blah blah blah"

    So you are right it says that it is going to "run" the query"....

    I press "Yes" and it opened fine...

    Yet when you open it with VBA it does not go into merge mode....hmmmm if you don't get an answer to this at this forum be sure to check out Microsoft's User Community Word Forum...I once has an obscure issue with a merge and got help there....

  5. #5
    Join Date
    Apr 2008
    Location
    All over, Now in Missouri
    Posts
    73

    Word Query frustration

    I am going to dig deeper to see what I can find. I found people upgrading from 2003 to 2007 have the same problem (of sorts).

    Peter
    We tend to look at Linear paths which can lead us to a path of resistance!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •