Results 1 to 2 of 2
  1. #1
    kmaccoy is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    2

    Linking Access to Word

    I am trying to export data from an Access record to a Word Form (I cannot use a report because this is a controlled company form).

    Most of the Access Fields have names that include spaces. I can get the code to work w/ the fields that have no spaces but w/ the other fields I get syntax errors:

    Set doc = appWord.Documents.Open("C:\WordForms\9386-6.docx", , True)


    With doc


    .FormFields("fldProgram").Result = Me!Program
    .FormFields("fldPlantCode").Result = Me!'Plant Code'


    It works fine for the Me!Program field but the Me!'Plant Code' field returns an debug error "Compile error: Type Mismatch" (it also removes the ! when I compile).

    The easy solution would be to rename the field names to something like PlantCode but this database is linked to so many other files that would create a whole other set of problems so I'd like to keep that as "plan B". Is there a syntax where I can get the second line to work just as well as the first line?

  2. #2
    kmaccoy is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    2
    I figured it out:

    .FormFields("fldProgram").Result = Me!Program
    .FormFields("fldPlantCode").Result = Me("Plant Code")

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

Similar Threads

  1. linking word document with access database
    By Gadai in forum Import/Export Data
    Replies: 1
    Last Post: 07-08-2016, 02:37 PM
  2. Linking Excel, Word and PDF files in Access 2013
    By accessmacroman in forum Import/Export Data
    Replies: 4
    Last Post: 03-08-2014, 03:29 PM
  3. Replies: 3
    Last Post: 11-13-2013, 11:55 AM
  4. Dynamically linking an Access Query to MS Word
    By delta9857 in forum Import/Export Data
    Replies: 2
    Last Post: 04-23-2012, 07:41 PM
  5. Linking Microsoft Word Form to Access Table
    By jrockusa in forum Access
    Replies: 1
    Last Post: 12-03-2009, 05:09 PM

Tags for this Thread

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