Private Sub cmdOutput_Click()
' Code Header inserted by VBA Code Commenter and Error Handler Add-In
'=============================================================
' Form_frmMyQueryResults.cmdOutput_Click
'-------------------------------------------------------------
' Purpose
' Author : Duane Hookom, Saturday, March 06, 2004
' Notes :
'-------------------------------------------------------------
' Parameters
'-----------
'
'-------------------------------------------------------------
' Returns:
'-------------------------------------------------------------
' Revision History
'-------------------------------------------------------------
' Saturday, March 06, 2004 dkh:
'=============================================================
' End Code Header block
'merge the fields from the query and the letter into a temporary table
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim intFldNum As Integer
On Error GoTo HandleErr
DoCmd.SetWarnings False
DoCmd.OpenQuery "qmakLettersTemp"
DoCmd.SetWarnings True
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM ttblLettersMerge")
With rs
If Not (.BOF And .EOF) Then
.MoveFirst
Do Until .EOF
For intFldNum = 4 To .Fields.Count - 1
.Edit
!ltrBody = Replace(!ltrBody, _
Chr(171) & .Fields(intFldNum).Name & Chr(187), _
.Fields(intFldNum) & "")
.Update
Next
.MoveNext
Loop
End If
.Close
End With
Set rs = Nothing
Set db = Nothing
DoCmd.OpenReport "rptQBFLetters", acPreview
ExitHere:
On Error Resume Next
'Close objects and set to nothing
Exit Sub
' Error handling block added by VBA Code Commenter and Error Handler Add-In. DO NOT EDIT this block of code.
' Automatic error handler last updated at Saturday, March 06, 2004 9:23:01 PM
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Form_frmMyQueryResults.cmdOutput_Click"
End Select
Resume ExitHere
' End Error handling block.
End Sub