Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking for a way to automatically update report into word.......

Status
Not open for further replies.

gnibbles

Programmer
Mar 15, 2000
79
CA
This may be a simple thing but Ive searched quite a bit and cant seem to find exactly what Im looking for. What Im trying to do is have a Microsoft Word document open up into a report and be able to search or fill the report based on certain parameters. Is this even possible through Word or will there HAVE to be direct use of Access?

Thanks

NT

gnibbles
 
Are you talking about mailmerge or automation?
 
I tried using mailmerge but came into a host of errors. But as well the mail merge procedure I followed only allowed for displaying of one record. I need to be able to display multiple records based on parameters. Almost like a search I guess......

gnibbles
 
Heres the code I used. I have certain fields commented out as I was troubleshooting and figured to try as little data as possible to try and get the darn thing working.

Private Sub Document_Open()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim strPath As String
Dim doc As Document


Set doc = ThisDocument
strSQL = "SELECT IssueID FROM tblInput ORDER BY IssueID"
strPath = "C:\Database\IssueReportingNew.mdb"
Set db = OpenDatabase(strPath)
Set rst = db.OpenRecordset(strSQL)
Do While Not rst.EOF
With doc.FormFields("txtIssueID").DropDown.ListEntries
.Add Name:=rst(0)
End With
rst.MoveNext
Loop
Set db = Nothing
Set rst = Nothing

End Sub


Sub FillDependentFields()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim doc As Document
Dim strSQL As String
Dim strPath As String

Set doc = ThisDocument
strSQL = "SELECT FirstName, LastName FROM tblInput " _
& "WHERE IssueID = '" _
& doc.FormFields("txtIssueID").Result _
& "'"
strPath = "c:\Database\IssueReportingNew.mdb"
Set db = OpenDatabase(strPath)
Set rst = db.OpenRecordset(strSQL)
On Error Resume Next
'doc.FormFields("txtDate").Result = rst(0).Value
doc.FormFields("txtFirst").Result = rst(0).Value
doc.FormFields("txtLast").Result = rst(1).Value
'doc.FormFields("txtIssue").Result = rst(2).Value
'doc.FormFields("txtApp").Result = rst(3).Value
'doc.FormFields("txtResp").Result = rst(4).Value
'doc.FormFields("txtSummary").Result = rst(5).Value
'doc.FormFields("chkIssue").Result = rst(7).Value
Set db = Nothing
Set rst = Nothing


End Sub


Private Sub Document_Close()
Dim doc As Document

Set doc = ThisDocument
doc.FormFields("txtIssueID").DropDown.ListEntries.Clear
'doc.FormFields("txtDate").TextInput.Clear
doc.FormFields("txtFirst").TextInput.Clear
doc.FormFields("txtLast").TextInput.Clear
'doc.FormFields("txtIssue").TextInput.Clear
'doc.FormFields("txtApp").TextInput.Clear
'doc.FormFields("txtResp").TextInput.Clear
'doc.FormFields("txtSummary").TextInput.Clear
'doc.FormFields("chkIssue").TextInput.Clear

ActiveDocument.Saved = True

End Sub


gnibbles
 
The code you have seems to be for updating bookmarks, rather than for a mailmerge. Here are two FAQs:

faq705-3827
faq705-3237
 
Thanks Ill try this and see how I do..... *Crossing fingers*

gnibbles
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top