Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 19th, 2004, 12:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Naperville, IL, USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Default Win '98 vs. Win XP

Dear fellow developers,

I have an application which automatically e-mails two reports. It runs correctly on Windows '98, however on Windows XP, only the first report is sent.

The application uses the following code:

Code:
Private Sub cmdRunReport_Click()
    Run_ActionReasonReports
End Sub

Sub Run_ActionReasonReports()
On Error GoTo Run_ActionReasonReports_Err

    Select Case MsgBox("Do you wish to run the Action Reason Reports Automatically?", vbYesNoCancel)
        Case vbYes
            If vbYes = MsgBox("Do you wish to manually edit the e-mail text?", vbDefaultButton2 + vbYesNo) Then
                EMailReport "rptOverallActionRsnForDateRange", True
                MsgBox "Send Next Report", , "PAUSE"
                EMailReport "rptActionRsnForDateRange", True
            Else
                EMailReport "rptOverallActionRsnForDateRange", False
                MsgBox "Send Next Report", , "PAUSE"
                EMailReport "rptActionRsnForDateRange", False
            End If
        Case vbNo
            DoCmd.OpenReport "rptOverallActionRsnForDateRange", acPreview
            MsgBox "Send Next Report", , "PAUSE"
            DoCmd.OpenReport "rptActionRsnForDateRange", acPreview
    End Select
    MsgBox "Reports E-Mailed", , "DONE"

Run_ActionReasonReports_Exit:
    Exit Sub

Run_ActionReasonReports_Err:
    MsgBox Error$
    Resume Run_ActionReasonReports_Exit

End Sub

Public Sub EMailReport(strReportName As String, blnEditEMail As Boolean)
On Error GoTo EMailReport_Err

    Dim strTo As String
    Dim strCC As String
    Dim strBC As String
    Dim strAuthor As String
    Dim strSubject As String
    Dim strMessage As String
    Dim strDear As String
    Dim intNameCount As Integer
    Dim intAuthorCount As Integer

    Dim cxn As ADODB.Connection
    Dim rst As ADODB.Recordset
    Dim strSQL As String

    Dim wnd As Long
    Dim uClickYes As Long
    Dim Res As Long

    Set cxn = CurrentProject.Connection
    Set rst = New ADODB.Recordset

    strSQL = "SELECT * FROM tblEMail_List"

    strTo = ""
    strCC = ""
    strBC = ""
    strDear = ""
    intNameCount = 0
    With rst
        .Open strSQL, cxn, adOpenForwardOnly, adLockReadOnly, adCmdText
        While Not .EOF
            Select Case !Type
                Case 1
                    If Len(Trim(strTo)) > 0 Then
                        strTo = strTo & "; "
                    End If
                    strTo = strTo & !EMail_Address
                    If intNameCount > 0 Then
                        strDear = strDear + " and "
                    Else
                        strDear = "Dear "
                    End If
                    strDear = strDear & !Name_First
                    intNameCount = intNameCount + 1

                Case 2
                    If Len(Trim(strCC)) > 0 Then
                        strCC = strCC & "; "
                    End If
                    strCC = strCC & !EMail_Address
                Case 3
                    If Len(Trim(strBC)) > 0 Then
                        strBC = strBC & "; "
                    End If
                    strBC = strBC & !EMail_Address
                Case 4
                    If intAuthorCount > 0 Then
                        strAuthor = strAuthor + " and "
                    End If
                    strAuthor = strAuthor & !Name_First
                    intAuthorCount = intAuthorCount + 1
            End Select

            Debug.Print !Name_Last, !Name_First, !EMail_Address, !Type
            .MoveNext
        Wend
        If Len(strDear) > 0 Then
            strDear = strDear + ":"
        End If
        Debug.Print "To: " & strTo
        Debug.Print "CC: " & strCC
        Debug.Print "BC: " & strBC
        Debug.Print "Dear: " & strDear
        Debug.Print "Author: " & strAuthor

        .Close
    End With

    Set rst = Nothing
    Set cxn = Nothing

    strSubject = "Action Reason Report - " & strReportName & " - From: " & Me.txtStartDate & " To: " & Me.txtEndDate

    Debug.Print "Subject: " & strSubject

    strMessage = strDear & String(2, Chr(10)) _
    & "Here is the Action Reason Report (" & strReportName & ") for the period from " & Format(Me.txtStartDate, "dddddd") _
    & " through " & Format(Me.txtEndDate, "dddddd") & "." & String(2, Chr(10)) & "In His Service," & String(2, Chr(10)) & strAuthor

    Debug.Print strMessage

    ' Register a message to send
'    uClickYes = RegisterWindowMessage("CLICKYES_SUSPEND_RESUME")

    ' Find ClickYes Window by classname
'    wnd = FindWindow("EXCLICKYES_WND", 0&)

    ' Send the message to Resume ClickYes
'    Res = SendMessage(wnd, uClickYes, 1, 0)

    If vbYes = MsgBox("Do you wish to send the report?", vbDefaultButton1 + vbYesNo + vbInformation, strReportName) Then
        DoCmd.SendObject acSendReport, strReportName, "SnapshotFormat(*.snp)", strTo, strCC, strBC, strSubject, strMessage, blnEditEMail
    End If

    ' Send the message to Suspend ClickYes
'    Res = SendMessage(wnd, uClickYes, 0, 0)

EMailReport_Exit:
    Exit Sub

EMailReport_Err:
    If Err = 2487 Then
        MsgBox "Please close and reopen report before sending it as a Snapshot.", , "Reporting Error"
    End If
    Resume EMailReport_Exit

End Sub


Why does this occur?

What changes do I need to make in order to run this on XP?


Thank you,


Rand
__________________
Rand


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report with win 98 os Arunachalam VB How-To 1 May 22nd, 2006 11:44 PM
deploying VB 6 pck with crystal rep 11 in Win 98 shantanu86 Pro VB 6 0 March 16th, 2006 09:49 PM
VB 6 and Crystal report 11 deployed on win 98 shantanu86 VB Components 0 March 16th, 2006 10:11 AM
win xp and web server Sus Beginning PHP 5 January 8th, 2006 10:40 AM
Can't Get Tomcat 5 to Run on Win 98 Lantaw JSP Basics 1 August 8th, 2003 04:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.