Populate Word Forms from Access Data-Not Mailmerge

kiki443

Board Regular
Joined
Feb 6, 2005
Messages
135
Hi,

I have an Access 2003 database where I log in application requests. I have added a button that "should" allow me to populate a Word form based on the data entered. I searched the internet and found and modified code to accomplish this. Please forgive me as I am very new to VBA. The problem I am having it duplicate fields are not populated.

On the form I have Fname and Lname on every page. It only populates for the first page, the rest are blank.

How should I fix this? Below is the code I am using. Any help would be appreciated.

Private Sub cmdPrint_Click()
'Print Application Packet for Applicant.
Dim objWord As Word.Application
Dim doc As Word.Document
'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("S:\Application Packet w_ Cover Letter.doc", , True)
With doc
.FormFields("fldFirstName").Result = Me![FIRST NAME]
.FormFields("fldLastName").Result = Me![LAST NAME]
.FormFields("fldDegree").Result = Me!Degree
.FormFields("fldAddress").Result = Me!Address
.FormFields("fldCity").Result = Me!City
.FormFields("fldState").Result = Me!State
.FormFields("fldZip").Result = Me!Zip
.FormFields("fldGroupName").Result = Me![Group Name]
.Visible = True
.Activate
End With
Set doc = Nothing
Set Appword = Nothing
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,215,085
Messages
6,123,030
Members
449,092
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top