Here is the code...
Code:
Private Sub CmdWordPrint_Click()
Dim Word As New Word.Application
Set Word = CreateObject("Word.Application")
Dim MergeDoc As String
MergeDoc = Application.CurrentProject.Path
MergeDoc = MergeDoc + "\PPFDIncidentReport.dotx"
Word.Documents.Add MergeDoc
Word.Visible = True
With Word.ActiveDocument.Bookmarks
txtIndex = ""
.Item("Index").Range.Text = Me.City
End With
End Sub
This only pulls the information from the current active record.
I was thinking about using something along the lines of this code below and modifying it to work for my db. I'm not really sure how this works.... Not sure what to sub for my titles and objects.
Code:
'Private Sub SetQuery(strQueryName As String, strSQL As String)
'On Error GoTo ErrorHandler
'Dim qdfNewQueryDef As QueryDef
'Set qdfNewQueryDef = CurrrentDb.QueryDefs(strQueryName)
'qdfNewQueryDef.SQL = strSQL
'qdfNewQueryDef.Close
'RefreshDatabaseWindow
'Exit Sub
'Error Handler:
'MsgBox "Error #" & Err.Number & " occurred. " & Err.Description, vbOKOnly, "Error"
'Exit Sub
'End Sub
'Private Sub cmdMergeIt_Click()
'On Error GoTo ErrorHandler
'Dim strPostalCode As String
'strPostalCode = txtPostalCode.Value
'Dim strSQL As String
'strSQL = "SELECT TblMembers.LastName, TblMembers.FirstName, TblMembers.Position, FROM TblMembers WHERE TblMembers.Status = ' " & strPostalCode & " ' ;"
'Dim strDocumentName As String
'strDocumentName = "\..........docx"
'Call SetQuery("qryLabelQuery", strSQL)
This code below is another option I was thinking about modifying for my db. Using a record set
Code:
'Dim mWord As Object
'Dim cnxn As ADODB.Connection
'Dim rL As ADODB.Recordset
'Set cnxn = CurrentProject.Connection
'Set rL = New ADODB.Recordset
'Set mWord = CreateObject("Word.Application")
'mWord.Documents.Add "C:\odis\odis_PPS_100_CaseClosing.dot"
'With mWord.ActiveDocument
'.Bookmarks("off_name").Range.Fields(1).Result.Text =
'GetOffenderName()
'rL.Open "current_sup", cnxn, adOpenForwardOnly, adLockReadOnly,
'adCmdTableDirect
'If Not rL.EOF Then
'..Bookmarks("cs_open_date").Range.Fields(1).Result .Text =
'rL.Fields ("cs_open_date")
'rL.Close
'.Bookmarks("sup_adjustment").Range.Fields(1).Resul t.Text =
'Nz(Forms("SupervisionForm")!memAdjustment, "")
'.Bookmarks("Today").Range.Fields(1).Result.Text = Date
'End With
'mWord.Visible = True
'Set mWord = Nothing
Thanks for any help.