Hi All,
OVERFLOW ERROR; doesn’t say where or what line or anything.
This Access Application has been working for years without any issue and now it gets an overflow error on the first email. It uses outlook to send emails out. I am having an issue tracking it down as no one has changed the code in anyway before this error started taking place. I do know you can get an overflow error on dividing by zero of a number field that has a number to large over "32,768" in size. I can't seem to find an error like that anywhere so far.
It basically goes through all the beginning processes without a problem. When it sends the first email that is when the overflow error happens.
[Clicking Send Button] --------------------------------------------------------------------------
Private Sub cmdSend_Click()
'On Error GoTo Err_cmdSend_Click
Dim sMsg As String
Dim iTotalEmailsSent As Integer
gCancelSendEmail = False
If Len(nts(Me.CampaignDate)) = 0 Then
sMsg = "Please enter campaign date." & nl()
End If
If Len(nts(Me.CampaignName)) = 0 Then
sMsg = sMsg & "Please enter campaign name." & nl()
End If
If Len(sMsg) > 0 Then
MsgBox sMsg, , "Validation"
Exit Sub
End If
sMsg = "You are about to send a large number of emails! Are you sure you want to continue?"
If vbYes = MsgBox(sMsg, vbYesNo, GC_APPLICATION_TITLE) Then
DoCmd.RunCommand (acCmdSaveRecord)
DoCmd.OpenForm "frm_Progress"
DoEvents
'main send email routine
SendEmail Me.CampaignID, iTotalEmailsSent 'SendEmail is doing the mailing.
'cleanup
Me.txtEmailsSent.Requery
DoCmd.Close acForm, "frm_Progress"
End If
Exit_cmdSend_Click:
Exit Sub
Err_cmdSend_Click:
MsgBox Err.Description, vbOKOnly, GC_APPLICATION_TITLE
GoTo Exit_cmdSend_Click
End Sub
--------------------------------------------------------------------------
[SENDMAIL] ---------------------------------------------------------------
Function SendEmail(lCampaignID As Long, iTotalEmailsSent As Integer)
On Error GoTo Err_SendEmail
Dim rst As ADODB.Recordset
Dim sTemplate As String
Dim sTemplateFileName
Dim sBody As String
Dim sEmail As String
Dim sSubject As String
Dim sEmailHTML As String
Dim oUtils As Object
Dim iErrorNumber As Integer
Dim sErrorDescription As String
Dim sDebugMode As String
Dim sDebugEmailAddress As String
Dim iDebugMaxEmailsToSend As Integer
sDebugMode = GetRegistry("DebugMode")
If sDebugMode = "on" Then
sDebugEmailAddress = GetRegistry("DebugEmailAddress")
iDebugMaxEmailsToSend = GetRegistry("DebugMaxEmailsToSend")
End If
miTotalEmailsSent = 0
gCancelSendEmail = False
sSubject = GetRegistry("EmailSubject")
'get external main email template file
sTemplateFileName = GetRegistry("TemplatePath") & "/" & GetRegistry("TemplateEmailFileName")
GetTemplate sTemplateFileName, sTemplate
'build table cache (performance only)
'note that the invoice_header table when "not" cached actually crashed the PC when running a query
Forms("frm_Progress").ProgressCaption = "Caching data ..."
If GetRegistry("CacheTables") <> "off" Then
BuildCache lCampaignID
End If
'Delete unsubscribes
DoCmd.SetWarnings False
DoCmd.OpenQuery "qdl_Unsubscribe", acViewNormal
DoCmd.SetWarnings True
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorLocation = adUseClient
Forms("frm_Progress").ProgressCaption = "Getting data ..."
DoEvents
rst.Open "qsl_Renewal", , adOpenDynamic, adLockReadOnly, adCmdStoredProc
DoEvents
rst.MoveLast
DoEvents
Forms("frm_Progress").ProgressMax = rst.RecordCount
Forms("frm_Progress").ProgressCaption = "Processing magazine"
rst.MoveFirst
While Not rst.EOF And Not gCancelSendEmail And Not (sDebugMode = "on" And miTotalEmailsSent >= iDebugMaxEmailsToSend)
GetBody lCampaignID, rst, sEmail, sBody
sEmailHTML = Replace(sTemplate, "###BODY###", sBody)
sEmailHTML = Replace(sEmailHTML, "###IMAGE_PATH###", GetRegistry("ImagePath"))
If sDebugMode = "off" Then
'MsgBox "Sending Email To Real Address!"
iErrorNumber = OutlookSendEmailSafe(sEmail, sSubject, sEmailHTML)
Else
iErrorNumber = OutlookSendEmailSafe(sDebugEmailAddress, sSubject, sEmailHTML)
End If
If iErrorNumber <> 0 Then
ErrorAdd lCampaignID, sEmail, iErrorNumber, sErrorDescription
End If
miTotalEmailsSent = miTotalEmailsSent + 1
DoEvents
Wend
If gCancelSendEmail Then
ErrorAdd lCampaignID, "", -1000, "User clicked the cancel button"
Forms("frm_Main").txtCancel = "Send Email Cancelled!"
End If
rst.Close
Set rst = Nothing
'force delivery of emails now (note bug in some outlook versions means send/receive needs to be pressed)
Set oUtils = CreateObject("Redemption.MAPIUtils")
oUtils.DeliverNow
Set oUtils = Nothing
iTotalEmailsSent = miTotalEmailsSent
Exit_SendEmail:
Exit Function
Err_SendEmail:
MsgBox Err.Description, vbOKOnly, GC_APPLICATION_TITLE
GoTo Exit_SendEmail
End Function
Function BuildCache(lCampaignID As Long)
Dim cat As ADOX.Catalog
Dim cmd As ADODB.Command
DoCmd.SetWarnings False
DoCmd.OpenQuery "qdl_FInvoice_Header_Cached", acViewNormal
DoEvents
'use local access table instead of SQL table
DoCmd.OpenQuery "qap_FInvoiceHeader_Cached", acViewNormal
DoEvents
'delete emails for people who have unsubscribed
DoCmd.OpenQuery "qdl_EmailUnsubscribe", acViewNormal
DoEvents
'use local access table instead of SQL table
DoCmd.OpenQuery "qdl_FStock_Cached", acViewNormal
DoEvents
DoCmd.OpenQuery "qap_FStock_Cached", acViewNormal
DoEvents
'use local access table instead of SQL table
DoCmd.OpenQuery "qdl_TitleMaster_Cache", acViewNormal
DoEvents
DoCmd.OpenQuery "qap_TitlesMaster_Cache", acViewNormal
DoEvents
DoCmd.SetWarnings True
'delete emails that have already been sent out for campaign (i.e. resend)
Set cat = New ADOX.Catalog
Set cmd = New ADODB.Command
cat.ActiveConnection = CurrentProject.Connection
Set cmd = cat.Procedures("qdl_EmailResend").Command
cmd.Parameters("[par_CampaignID]").Value = lCampaignID
cmd.Execute
Set cmd = Nothing
Set cat.ActiveConnection = Nothing
Set cat = Nothing
End Function
---------------------------------------------------------------
Looking for any ideas on where to start; I do know it happens when the first email is being sent. That would eliminate a lot I would think.
Any help is appreciated,
Thanks