[AccessD] Print letter from InputBox data (contains long code)

Bob Gajewski bob at renaissancesiding.com
Fri Jun 20 07:52:39 CDT 2003


Doris

Well, that worked - sort of.

I moved all of the InputBox code to the Report_Open module, and now the 
report is being created and printing properly EXCEPT that it is printing 
the letter TWICE.

I have checked all of the page setup and printer attributes; there is 
nothing that would force two copies.

Any ideas on this new twist?

TIA,
Bob

On Thursday, June 19, 2003 14:44 PM, Mike and Doris Manning 
[SMTP:mikedorism at ntelos.net] wrote:
> Doris
> When you print the open preview, some of the sections of the report rerun 
on
> the way to the printer so that's why you are getting the second pass for
> information
>
> Try moving the Input box code to the Report's Open event instead
>
> Doris Manning
> Database Administrator
> Hargrove Inc
> www.hargroveinc.com
>
**********************************************
Option Compare Database
Option Explicit
Public gvarRecordFound As Boolean
Public strInput1 As String
Public strInput2 As String
Public strInput3 As String
Public strInput4 As String
Public strInputS As String
Public strInputT As String
Private Sub Report_NoData(Cancel As Integer)
Dim Msg, Response
    Msg = "This report is not available; no records exist."
    Response = MsgBox(Msg, vbInformation)
DoCmd.CancelEvent
End Sub
----------------------------------------------------------
Private Sub Report_Open(Cancel As Integer)

'Allow user to enter text for paragraphs 1-4
    Dim strMsg1 As String
        strMsg1 = "Please enter the text for paragraph 1:"
        strInput1 = InputBox(Prompt:=strMsg1, Title:="Paragraph 1")
        If Not (IsNull(strInput1) Or strInput1 = "") Then
            Dim strMsg2 As String
                strMsg2 = "Please enter the text for paragraph 2:"
                strInput2 = InputBox(Prompt:=strMsg2, Title:="Paragraph 2")
                If Not (IsNull(strInput2) Or strInput2 = "") Then
                    Dim strMsg3 As String
                        strMsg3 = "Please enter the text for paragraph 3:"
                        strInput3 = InputBox(Prompt:=strMsg3, 
Title:="Paragraph 3")
                        If Not (IsNull(strInput3) Or strInput3 = "") Then
                            Dim strMsg4 As String
                                strMsg4 = "Please enter the text for 
paragraph 4:"
                                strInput4 = InputBox(Prompt:=strMsg4, 
Title:="Paragraph 4")
                                If Not (IsNull(strInput4) Or strInput4 = 
"") Then
                                End If
                        End If
                End If

            'Allow user to enter text for signator and title
                Dim strMsgS As String
                    strMsgS = "Please enter the signator's name:"
                    strInputS = InputBox(Prompt:=strMsgS, 
Title:="Signator")
                    If Not (IsNull(strInputS) Or strInputS = "") Then
                        Dim strMsgT As String
                            strMsgT = "Please enter the signator's title:"
                            strInputT = InputBox(Prompt:=strMsgT, 
Title:="Title")
                            If Not (IsNull(strInputT) Or strInputT = "") 
Then
                            End If
                    End If
        Else
            MsgBox "There was no text entered for Paragraph 1."
            Cancel = True
            gvarRecordFound = False
        End If

End Sub
----------------------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

gvarRecordFound = True

Dim MyPos
    MyPos = InStr(1, [txtJobHomeownerName], ",")

If MyPos > 0 Then
    Me.txtLetterName = Mid([txtJobHomeownerName], MyPos + 1, 35) & " " & 
Left([txtJobHomeownerName], MyPos - 1)
    Me.txtSalutation = "Dear " & Mid([txtJobHomeownerName], MyPos + 1, 35) 
& " " & Left([txtJobHomeownerName], MyPos - 1) & ":"
Else
    Me.txtLetterName = [txtJobHomeownerName]
    Me.txtSalutation = "Dear " & [txtJobHomeownerName] & ":"
End If

If Left([txtLetterName], 1) = " " Then
    [txtLetterName] = Mid([txtLetterName], 2, 35)
End If

If Left([txtSalutation], 1) = " " Then
    [txtSalutation] = Mid([txtSalutation], 2, 41)
End If

    Me.txtLetterAddress = [txtJobAddress]
    Me.txtLetterLocation = [txtJobMunicipalityName] & ", " & 
[txtJobStateCode] & " " & [txtJobZipCode]
    Me.txtClaimNumber = "'" & [txtJobCompanyReference] & "'"

    Me.txtParagraph1 = strInput1

    If Not (IsNull(strInput2) Or strInput2 = "") Then
        Me.txtParagraph2 = strInput2
    End If

    If Not (IsNull(strInput3) Or strInput3 = "") Then
        Me.txtParagraph3 = strInput3
    End If

    If Not (IsNull(strInput4) Or strInput4 = "") Then
        Me.txtParagraph4 = strInput4
    End If

    If Not (IsNull(strInputS) Or strInputS = "") Then
        Me.txtSignator = strInputS
        Me.txtSignatorTitle = strInputT
    Else
        Me.txtSignator = "Renaissance Siding"
        Me.txtSignatorTitle = ""
    End If

End Sub
----------------------------------------------------------
Private Sub Report_Close()
If gvarRecordFound = False Then
    Exit Sub
End If
Dim db As Database, rs As Recordset
Dim Response
Dim strMsgPrint As String
    strMsgPrint = "Did the letter print properly?"
If vbNo = MsgBox(strMsgPrint, vbYesNo + vbQuestion, "Print Letter 
Verification") Then
    Response = acDataErrDisplay
Else
    'Add letter subject to comments
    Dim strInput As String, strMsg As String
        strMsg = "What was the subject of this letter?"
        strInput = InputBox(Prompt:=strMsg, Title:="Subject")
        If IsNull(strInput) Or strInput = "" Then
            strInput = "NOT SPECIFIED"
        End If
    Set db = CurrentDb
    Set rs = db.OpenRecordset("tblJobComments", dbOpenDynaset)
    On Error Resume Next
    rs.AddNew
        Dim strComment As String
            strComment = "HOMEOWNER LETTER PRINTED (SUBJECT: " & 
UCase(strInput) & ")."
        rs!lngJobID = lngJobID
        rs!txtJobComment = strComment
        rs!dteJobCommentNow = Now()
        rs!cboJobCommentPrivate = False
    rs.Update
    If Err Then
        MsgBox "An error occurred, and the comments were not updated." & 
vbCrLf & "Remember to add a comment to the database" & vbCrLf & "record 
indicating that the letter was sent today."
        Response = acDataErrContinue
    Else
        Response = acDataErrAdded
    End If
    rs.Close
End If
End Sub
**********************************************




More information about the AccessD mailing list