Well I've hit another brick wall. I can't seem to get the following code to work.
It is designed to take information from the form in access, and dump it onto a word form. The form is multiple pages long, and contains repetions of the four fields listed above. (more than the four listed, but they're taken out to shorten the code)
I don't get any errors, just a document that pops up, with the formfields still blank.
Any help on this would be greatly appreciated.
Thanks!
Code:
Private Sub Command112_Click()
'Print customer slip for current customer.
Dim appWord As Word.Application
Dim doc As Word.Document
Dim docdoc As String
docdoc = Application.CurrentProject.Path
docdoc = docdoc + "\printouts.docx"
'Avoid error 429, when Word isn't open.
On Error Resume Next
Err.Clear
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'If Word isn't open, create a new instance of Word.
Set appWord = New Word.Application
End If
Set doc = appWord.Documents.Open(docdoc, , True)
With doc
.FormFields("WORDfirst").Result = Me!firstname
.FormFields("WORDlast").Result = Me!lastname
.FormFields("WORDrank").Result = Me!Text23
.FormFields("WORDwcn").Result = Me!wcn
.Visible = True
.Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
End Sub
It is designed to take information from the form in access, and dump it onto a word form. The form is multiple pages long, and contains repetions of the four fields listed above. (more than the four listed, but they're taken out to shorten the code)
I don't get any errors, just a document that pops up, with the formfields still blank.
Any help on this would be greatly appreciated.
Thanks!