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?