Results 1 to 6 of 6
  1. #1
    dgmdvm is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2014
    Posts
    84

    Mail Merge on a workstation problem

    I have almost completed my database and one of my last steps was to split the database and test it on another computer. Every feature works except for the mail merge feature. The mail merge code works fine when the front end and back end of the database are on the same machine but after I loaded my front end database onto my laptop, it can't open the data source (a query) to complete the merge. I did not use the Windows homegroup feature; I just shared the folder the database files are in. I can view and open the files on my laptop with no problem, I can run all the queries and forms of my database with no problems, I just can't get the merge to run.



    In the following code, the variable "pathname" is C:\users\david\documents\database files on the machine where the back end resides; "pathname" is \\wks0\users\david\documents\database files on my laptop. The computer with the back end database on it is named wks0.

    Code:
    Private Sub cmdMerge_Click()' opens Microsoft Word to create a Mail merge letter
    On Error GoTo Err_CmdMerge_Click
    Dim objWord As New Word.Application
    Dim objDoc As Word.Document
    Dim Docpath As String
    Dim DBpath As String
    Dim pathname As Variant
    pathname = DLookup("[docpath]", "Files_settings")
           DoCmd.RunCommand acCmdAppMinimize
           objWord.Application.visible = True
         
          Docpath = pathname & "\GOMOC letter.docx"
          DBpath = pathname & "\Gomoc database.accdb"
        
           Set objDoc = objWord.Documents.Open(Docpath)
          
           objWord.WindowState = wdWindowStateMaximize
           
          If Err.number <> 0 Then
             Set objWord = CreateObject("Word.Application")
          End If
           
            
           With objDoc.MailMerge
                   .MainDocumentType = wdFormLetters
                   .ShowWizard InitialState:=2
                   .OpenDataSource DBpath, sqlstatement:="SELECT * FROM [Mail Merge Query]", OpenExclusive:=False
                   '.Execute If you add this line, it completes the mail merge and opens a new word docuement with all the letters in it
                              
           End With
           
           objWord.Documents(Docpath).Activate
           Set objWord = Nothing
           
           Set objDoc = Nothing
       
    Exit_Err_CmdMerge_Click:
     Exit Sub
      
    Err_CmdMerge_Click:
    MsgBox Err.Description
    Resume Exit_Err_CmdMerge_Click
    
    
    End Sub
    When I try to run the code I get an error that says "Could not find file '\\wks0\users\david\documents\database files.mdb'

    Any ideas?

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    I would add a debug print to verify the path

    Code:
     DBpath = pathname & "\Gomoc database.accdb"
     debug.print DBpath
    Also you do know that access over wireless is destined to be a problem.

    I would also take a look at Albert Kallal's Super easy word merge. There's a lot to learn by looking over his code and his methods.
    One thing that always made sense to me is not allowing word to connect directly to access. He explains it in detail in his notes.

    http://www.kallal.ca/msaccess/msaccess.html

  3. #3
    dgmdvm is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2014
    Posts
    84
    Also you do know that access over wireless is destined to be a problem.
    No, I wasn't aware that it would be problematic; At home it seems to work fine but I will take your word of warning and keep connections wired.


    I would also take a look at Albert Kallal's Super easy word merge.
    I have looked this over before and as I recall I borrowed snippets the code from it. I don't recall the notes section so I will check it out. Thanks

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Just to add to moke's advice, I've used albert kallal's code for over 10 years in a variety of setups.
    Most of these have split databases with Access or SQL BE. Neither are a problem with his code.

    Wireless connections WILL cause corruption. AVOID.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    You may want to consider just using Alberts code, why re-invent the wheel.
    I use it extensively and have never had any problems with it. I also find it to be extremely adaptable. You can confiqure it in many ways.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Mail Merge problem
    By cbende2 in forum Access
    Replies: 3
    Last Post: 07-11-2014, 02:13 PM
  2. Mail merge problem
    By Affendi in forum Import/Export Data
    Replies: 6
    Last Post: 02-08-2011, 07:38 AM
  3. Access / Word mail merge problem.
    By PD1117 in forum Access
    Replies: 0
    Last Post: 07-06-2010, 09:41 AM
  4. Mail merge
    By grgerhard in forum Forms
    Replies: 0
    Last Post: 04-25-2006, 05:06 PM
  5. Mail Merge problem
    By kfergus in forum Programming
    Replies: 0
    Last Post: 04-24-2006, 01:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums