The db I use has code (below) to send an email to an individual, based
on the completion of an action with the record. This many happen for
one record at a time, or 25 records at a time, some sequential, some
not.
Problem is it only works sometimes. Generally, if I try to use it on a
second record in a series, it LOOKS like it is working (the status bar
in the lower left says "calculating..." then returns to form view), but
does not actually DO the process. But sometimes it works flawlessly for
any number of record updates, and then stops working with no indication
of a problem. And there is no telling when it will work and when it
won't. It doesn't throw a debug at me and I have to close the db to be
able to get it to work.
I am not SQL savvy enough to figure what is or isn't working. Any
ideas?
Thanx,
Sam
CODE
Private Sub chkspvsr_Click()
On Error GoTo Err_chkspvsr_Click
Dim CHK As Integer
Dim BNum As Variant
Dim Client As String
Dim email As String
Dim DScrip As Variant
DScrip = Me!Descr
BNum = Me!txtBCRNum
Client = Me!txtClientName
CHK = Me!chkspvsr
If CHK = -1 Then
Me!lblMsg.Visible = True
DoCmd.SendObject , , acFormatTXT, "User.Name@Company.com", , , "BCR
# '" & _
BNum & "' for '" & Client & "' is TESTED and COMPLETE.",
"DESCRIPTION OF CHANGE - " & DScrip
Me!lblMsg.Visible = False
Else: Exit Sub
End If
Exit_chkspvsr_Click:
Exit Sub
Err_chkspvsr_Click:
Me!lblMsg.Visible = False
MsgBox Err.Description
Resume Exit_chkspvsr_Click
End Sub
pietlinden@hotmail.com - 12 Feb 2005 04:28 GMT
So you change the Sub to a Function and make the return value a
Boolean. At the top of the function, you declare the default value to
false. If the mail sends, you set it to true. In the error trapping,
you set it to false. Then if the function returns False, you do
something - flag the record, write the failure to a table, whatever.