When I run the following code, I get "'Run Time Error 3061' -Too few Parameters. Expected 3". The line that I get the error on is noted below. Any help is appreciated. (Code courtesy of PHV)
Private Sub Command272_Click()
Dim DB As Database
Dim objWord As Object
Dim rs As DAO.Recordset
'Open Word, import the text to the bookmarks and display the letter
Set objWord = New Word.Application
objWord.Visible = True
'Open Your Recordset and move to the first record
Set DB = CurrentDb
Set rs = DB.OpenRecordset("AdminReport_Final", dbOpenDynaset) ****ERROR 3061***
rs.MoveFirst
'Loop through each record of the rs, inserting each field of the record into a Bookmark in the template
Do Until rs.EOF
Set objWordDoc = objWord.Documents.Add(Template:="c:\Monthly_Report_Template.dot", NewTemplate:=False)
With objWordDoc.Bookmarks
.Item("Recap").Range.Text = rs.Fields(1)
End With
Loop
objWord.Quit
Set objWord = Nothing
End Sub
Private Sub Command272_Click()
Dim DB As Database
Dim objWord As Object
Dim rs As DAO.Recordset
'Open Word, import the text to the bookmarks and display the letter
Set objWord = New Word.Application
objWord.Visible = True
'Open Your Recordset and move to the first record
Set DB = CurrentDb
Set rs = DB.OpenRecordset("AdminReport_Final", dbOpenDynaset) ****ERROR 3061***
rs.MoveFirst
'Loop through each record of the rs, inserting each field of the record into a Bookmark in the template
Do Until rs.EOF
Set objWordDoc = objWord.Documents.Add(Template:="c:\Monthly_Report_Template.dot", NewTemplate:=False)
With objWordDoc.Bookmarks
.Item("Recap").Range.Text = rs.Fields(1)
End With
Loop
objWord.Quit
Set objWord = Nothing
End Sub