 |
| 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
|
|
|
|

February 19th, 2004, 12:30 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |