Email Notifications not working using Access Runtime (1 Viewer)

randallst

Registered User.
Local time
Today, 08:17
Joined
Jan 28, 2015
Messages
64
That's exactly what I was thinking earlier. The DLookup() functions were failing, so the actual problem had nothing to do with sending the email in runtime.

Did you try the replacement code I suggested earlier?
Sorry I think we're confusing each other now.

I have added your DLookup into the VBA code and it comes up with this on the Full Microsoft Access
Untitled.png


When i try and run it on Runtime, i get this
Untitled.png


Before changing the DLookup, the original one worked fine on the Full Microsoft Access.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:17
Joined
Oct 29, 2018
Messages
21,471
Sorry I think we're confusing each other now.

I have added your DLookup into the VBA code and it comes up with this on the Full Microsoft Access
View attachment 86322

When i try and run it on Runtime, i get this
View attachment 86323

Before changing the DLookup, the original one worked fine on the Full Microsoft Access.
Okay, let's start over then. Could you please post the entire code you're using/running in the Runtime Access? Thanks.
 

randallst

Registered User.
Local time
Today, 08:17
Joined
Jan 28, 2015
Messages
64
Okay, let's start over then. Could you please post the entire code you're using/running in the Runtime Access? Thanks.
Code:
Private Sub Email_Notification_Button_Click()

'This function emails out an notification email to recipients to flag a Internal Incident has been raised

If MsgBox("Would you like to send an email notification to highlight concern?", vbYesNo + vbQuestion, "Email Notification") = vbYes Then

'send email notification
Dim ccto As String
Dim bccto As String
Dim mailto As String

'Mail Recipients
mailto = DLookup("Email", "Tbl_Users", "Name=" & "Investigation_Lead")
ccto = DLookup("Email", "Tbl_Users", "Alias=" & "Customer")
bccto = ""

'Email Subject
mailsub = "NEW INTERNAL CONCERN: " & Me.Full_ID & ""

'Email Message
emailmsg = "Incident ID: " & Me.Full_ID & vbNewLine & "Category: " & Me.Category & vbNewLine & "Incident Owner: " & DLookup("Name", "Tbl_Users", "Alias=" & "Customer") & vbNewLine & "Product: " & Me.Product & " " & Me.Denomination & vbNewLine & "Title: " & Me.Complaint_Description & vbNewLine & vbNewLine & "Please liaise with the Incident Owner for further information in relation to the above concern."

'On Error Resume Next
DoCmd.SendObject acSendNoObject, , , mailto, ccto, bccto, mailsub, emailmsg, False

DoCmd.Save
DoCmd.Close

Else

DoCmd.Save
DoCmd.Close
Exit Sub

End If

End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:17
Joined
Oct 29, 2018
Messages
21,471
Okay, thanks. Remember, at this point, we just want to avoid the error, okay? With that in mind, try replacing all that with this:
Code:
Private Sub Email_Notification_Button_Click()

'This function emails out an notification email to recipients to flag a Internal Incident has been raised

If MsgBox("Would you like to send an email notification to highlight concern?", vbYesNo + vbQuestion, "Email Notification") = vbYes Then

'send email notification
Dim ccto As String
Dim bccto As String
Dim mailto As String

'Mail Recipients
mailto = DLookup("Email", "Tbl_Users", "Name='Investigation_Lead'")
ccto = DLookup("Email", "Tbl_Users", "Alias='Customer'")

MsgBox "mailto: " & mailto & vbCrLf & "ccto: " & ccto

End If

DoCmd.Close acForm, Me.Name

End Sub
Please post a screenshot of the result. As we eliminate each error, we'll build up this code.
 

Minty

AWF VIP
Local time
Today, 08:17
Joined
Jul 26, 2013
Messages
10,371
Sorry I think we're confusing each other now.

I have added your DLookup into the VBA code and it comes up with this on the Full Microsoft Access
View attachment 86322

When i try and run it on Runtime, i get this
View attachment 86323

Before changing the DLookup, the original one worked fine on the Full Microsoft Access.
PMFJI but you need to capture the 2501 error. You will always get this if you cancel sending the email, in the full version you can just click ok and the error disappears. The runtime can't do that, so you need to examine the error code returned and handle it.

The other problems are as @theDBguy and others suggested, issues with your Dlookup's failing.
 

Users who are viewing this thread

Top Bottom