Export 10+ Access fields to Word w/ 'with doc... end with'

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with a 'print' command button that exports the data in the form fields from MS Access into MS Word form fields. I've followed the instructions from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnima02/html/ima0102.asp. My problem is with the section
With do
.FormFields("fldSalutation").Result = Nz(Me!TitleOfCourtesy
.FormFields("fldName").Result = Nz(Me!FirstName & " " & Me!LastName
.FormFields("fldTitle").Result = Nz(Me!Title
.FormFields("fldHireDate").Result = Nz(Me!HireDate
.FormFields("fldApprovedBy").Result = strReportsT
End Wit
If I try to add more than 6 lines between 'with doc' and 'end with' error messages '4120Bad Parameter. And, when I open the MS Word template, it will slowly populate the first few fields but then won't populate the remaining fields listed in the code.
 
There's no obvious reason why this sort of code should work with 6
statements and fail with 7. Make absolutely certain that you're not
mistyping any of the names of formfields, Access controls, or whatever.
But if we can't see your code and you don't tell us at which line it
fails, there's not much more to say.

I have a form with a 'print' command button that exports the data in
the form fields from MS Access into MS Word form fields. I've followed
the instructions from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnima02/html/ima0102.asp.
My problem is with the section:
With doc
.FormFields("fldSalutation").Result = Nz(Me!TitleOfCourtesy)
.FormFields("fldName").Result = Nz(Me!FirstName & " " & Me!LastName)
.FormFields("fldTitle").Result = Nz(Me!Title)
.FormFields("fldHireDate").Result = Nz(Me!HireDate)
.FormFields("fldApprovedBy").Result = strReportsTo
End With
If I try to add more than 6 lines between 'with doc' and 'end with' error
messages '4120Bad Parameter. And, when I open the MS Word template, it
will slowly populate the first few fields but then won't populate the
remaining fields listed in the code.
 
Back
Top