I found several threads on this topic, but could not find an appropriate solution for my issue.
I created a database (frontend/backend) for my team where the frontend is installed on their PC and the backend table is located on a shared network. There can be as many 30 folks in the backend table at one time with about 40 tables (most of which have less than a few hundred rows and less than 20 columns/fields).
The issue that is some folks (some of the time) experience the database crashing after sending an e-mail (event after clicking a checkbox, changing a drop-down menu, entering a figure into a textbox, etc).
Below is a my coding for one of the events (names/fields/messages changed to protect the innocent):
Private Sub Text128_AfterUpdate()
Dim mymsg As String
mymsg = "messageline1" & vbCrLf
mymsg = mymsg & "messageline2" & vbCrLf
mymsg = mymsg & "messageline3" & [text1] & vbCrLf
mymsg = mymsg & "messageline4" & [text2] & vbCrLf
mymsg = mymsg & "messageline5" & [text3] & vbCrLf
mymsg = mymsg & "messageline6" & [text4] & vbCrLf
If Text128 = -1 Then
DoCmd.SendObject acSendNoObject, , , DLookup("", "[table1]", "[field1] = '" & [text5] & "'"), "person1@email.com; person2@email.com; person3@email.com; person4@email.com; person5-lastname@email.com; person6@email.com", , [text6] & "subjectmessage" & [text7], mymsg, True
End If
End Sub
i intentionally left the hyphen in person5's name in case that could be an identifying issue (although, I would HOPE that it shouldn't matter). The crash happens quite frequently, but when the user removes the names and has just one name in the CC: box, then it does NOT crash. The e-mail does get sent though, but obviously, I don't want the database to crash.
below is a second coding from a different form:
Private Sub text1_Click()
If Me!text1 = -1 Then
Me!text2 = Forms![frm1].[user_name]
Me!text2 = Now()
Me!field1 = Forms![frm1].[user_name]
Me!field2 = Now()
Dim message As String
message = "message1"
If MsgBox(message, vbYesNo, "comment") = vbNo Then
Dim strwhere As String
strwhere = "[field3] = """ & Me.[text3] & """"
Debug.Print strwhere
If DLookup("[Email]", "table1", strwhere) <> "NoEmail" Then
DoCmd.SendObject acSendNoObject, , , DLookup("[Email]", "table1", strwhere), , , "message2" & DLookup("[field3]", "table1", strwhere), , True
End If
End If
End If
Exit Sub
ErrorHandler:
DoCmd.CancelEvent
MsgBox Err.Description & " " & Err.Number, vbCritical, "File Export"
End Sub
For this second event, the crash happens about 5% of the time for everyone on the team collectively. The crash is not consistent enough to develop a pattern (not the same field3 name, not the same time of day/month, etc).
any ideas would be greatly appreciated.
thanks!
I created a database (frontend/backend) for my team where the frontend is installed on their PC and the backend table is located on a shared network. There can be as many 30 folks in the backend table at one time with about 40 tables (most of which have less than a few hundred rows and less than 20 columns/fields).
The issue that is some folks (some of the time) experience the database crashing after sending an e-mail (event after clicking a checkbox, changing a drop-down menu, entering a figure into a textbox, etc).
Below is a my coding for one of the events (names/fields/messages changed to protect the innocent):
Private Sub Text128_AfterUpdate()
Dim mymsg As String
mymsg = "messageline1" & vbCrLf
mymsg = mymsg & "messageline2" & vbCrLf
mymsg = mymsg & "messageline3" & [text1] & vbCrLf
mymsg = mymsg & "messageline4" & [text2] & vbCrLf
mymsg = mymsg & "messageline5" & [text3] & vbCrLf
mymsg = mymsg & "messageline6" & [text4] & vbCrLf
If Text128 = -1 Then
DoCmd.SendObject acSendNoObject, , , DLookup("", "[table1]", "[field1] = '" & [text5] & "'"), "person1@email.com; person2@email.com; person3@email.com; person4@email.com; person5-lastname@email.com; person6@email.com", , [text6] & "subjectmessage" & [text7], mymsg, True
End If
End Sub
i intentionally left the hyphen in person5's name in case that could be an identifying issue (although, I would HOPE that it shouldn't matter). The crash happens quite frequently, but when the user removes the names and has just one name in the CC: box, then it does NOT crash. The e-mail does get sent though, but obviously, I don't want the database to crash.
below is a second coding from a different form:
Private Sub text1_Click()
If Me!text1 = -1 Then
Me!text2 = Forms![frm1].[user_name]
Me!text2 = Now()
Me!field1 = Forms![frm1].[user_name]
Me!field2 = Now()
Dim message As String
message = "message1"
If MsgBox(message, vbYesNo, "comment") = vbNo Then
Dim strwhere As String
strwhere = "[field3] = """ & Me.[text3] & """"
Debug.Print strwhere
If DLookup("[Email]", "table1", strwhere) <> "NoEmail" Then
DoCmd.SendObject acSendNoObject, , , DLookup("[Email]", "table1", strwhere), , , "message2" & DLookup("[field3]", "table1", strwhere), , True
End If
End If
End If
Exit Sub
ErrorHandler:
DoCmd.CancelEvent
MsgBox Err.Description & " " & Err.Number, vbCritical, "File Export"
End Sub
For this second event, the crash happens about 5% of the time for everyone on the team collectively. The crash is not consistent enough to develop a pattern (not the same field3 name, not the same time of day/month, etc).
any ideas would be greatly appreciated.
thanks!