By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,773 Members | 2,307 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,773 IT Pros & Developers. It's quick & easy.

A2k: Module stops executing after OpenReport, SendObject

P: n/a
I'm having a very strange problem that currently defies explanation. I
use the code below to send a status report to a client. The intent is
to send the user the report via fax using WinFax and/or email it using
Outlook. The problem is that after executing the DoCmd.OpenReport
command (fax) or DoCmd.SendObject command (email), the code simply
stops running. No error message, no indication that there is a logical
reason for this code to stop running. What is wrong, and how do I
change it?

Here is the code in which the commands are issued.

Public Sub Process()

Dim strQuery As String

' 1. Update the list of records that are not marked as Completed.
DoCmd.OpenQuery "qryInsertIncompleteTickets"

' 2. Get list of those that were incomplete that are now
Completed.
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("qrySelectCompletedTickets ")
Do Until rst.EOF

Dim intTicket As Integer
intTicket = rst("AutomaticTicketCtr")
SetParameter intTicket, 1

' Fax message.
Dim strFax As String
strFax = rst("BillToFax")
If rst("PODFaxSend") And Not IsNull(strFax) And strFax <> ""
Then
MsgBox "Sending fax."
Dim objSend As Object
Set objSend = CreateObject("WinFax.SDKSend8.0")
With objSend
.SetNumber strFax
.SetTo rst("ClientName")
.AddRecipient
.SetPreviewFax 1
.SetPrintFromApp 1
.Send 1
Do While .IsReadyToPrint = 0
DoEvents
Loop
DoCmd.OpenReport "rptFaxPODtoCustomer", acViewNormal
MsgBox "Report opened."
' SleepAPI 200
.Done
' SleepAPI 200
MsgBox "Exiting with."
End With
' Mark ticket as fax sent.
DoCmd.OpenQuery "qryUpdateTicketMarkPODFaxSent"
' Record a log of the activity.
strQuery = "INSERT INTO tblLog VALUES (#" & Now & "#, " &
intTicket & ", 'fax', '" & strFax & "')"
CurrentDb.Execute strQuery
MsgBox "Fax sent."
End If

' Email message.
Dim strEmail As String
Dim strMessage As String
strEmail = rst("EmailAddress")
If rst("PODEmailSend") And Not IsNull(strEmail) And strEmail
<> "" Then
MsgBox "Sending email."
DoCmd.SendObject acSendReport, "rptFaxPODtoCustomer",
acFormatHTML, strEmail, , , "subject", strMessage
' Mark ticket as fax sent.
DoCmd.OpenQuery "qryUpdateTicketMarkPODEmailSent"
' Record a log of the activity.
strQuery = "INSERT INTO tblLog VALUES (#" & Now & "#, " &
intTicket & ", 'email', '" & strEmail & "')"
CurrentDb.Execute strQuery
MsgBox "Email sent."
End If
Loop

' 3. Delete the records that were marked.
MsgBox "Deleting sent records."
DoCmd.OpenQuery "qryDeleteSentTickets"
MsgBox "Deleting sent records: done."

End Sub

-- Jay Bienvenu
Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.