Results 1 to 8 of 8
  1. #1
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Mail Merge (Access 2003 SP2)

    I get the message "Error! Cannot open data source." when running a mail merge from Access.

    What does this mean?

    The attached routine should produce the mail merge, it crashes with MergeIt = 4 which indicates the bolded command fails.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Mail Merge (Access 2003 SP2)

    Try inserting the following line just before setting the data source (you could put it above the line <code>If Left(sSql, 6) = "SELECT" Then</code>)
    <code>
    objWord.MailMerge.MainDocumentType = wdFormLetters</code>

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Mail Merge (Access 2003 SP2)

    I put that before the If statement and it produced the following error after executing the statement after the If.

    I have used this routine in another database and it works fine.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Mail Merge (Access 2003 SP2)

    By editing the code, you have locked the database for exclusive use. You will have to save your changes, then close and reopen the database. Then run the code (without modifying it)

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Mail Merge (Access 2003 SP2)

    Yes, that was right.
    It made no difference.
    I have included a zip file that shows what happens in order of the files.

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Mail Merge (Access 2003 SP2)

    Can i go into the word document and manually run it from there to see if it can access the Access query from there?

    It may be a problem in my word document?

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Mail Merge (Access 2003 SP2)

    You could try, but I think it is a coding problem because destination has a small d.

    If the code was correct, this would change automatically to a Captial D.
    (unless it has been changed by Word back to small d- but other similar things have not.)

    Do you get any errors if you compile the code?

    In the cases that fail is the data source a query or a table or an sql statement?
    Regards
    John



  8. #8
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Mail Merge (Access 2003 SP2)

    Thanks for your time John, but i solved the problem by creating the document afresh.

    I knew it couldn't be a Access coding problem as i have used that code in 3 other databases without any problems, but i guess, stranger things have happened.

Posting Permissions

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