I'm far from knowledgeable when it comes to Access but am teaching myself slowly.
I'm trying to make a form email details of itself after update (saving/closing etc...) if a checkbox is selected.
This is what I have so far. The code doesn't error but also doesn't send me an email?
----------------------
Private Sub Form_AfterUpdate()
If Engineer_Callback_Requried = "True" Then
'******begin code******
Dim email, subject1, Title, Customer, Company, mobilenumber, openedby, Description As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**gathers information from your form. this sets the string variable to your fields
email = "my@email.com"
subject1 = "Engineer Callback Required"
Title = Me!Title
Customer = Me!Customer
Company = Me!Company
mobilenumber = Me!Mobile_Phone
openedby = Me!Opened_By
Description = Me!Description
'***creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'***creates and sends email
With objEmail
.To = email
.subject = subject1 & " " & Title & " "
.Body = Customer & " " & Company & " "
.Body = mobilenumber & " "
.Body = openedby & " "
.Body = Description & " "
.Send
End With
'**closes outlook
Set objEmail = Nothing
objOutlook.Quit
End If
End Sub
--------------------
If I run this from a button taking the if statement out then it works ok.
What am I missing? Is this even possible?
I'm trying to make a form email details of itself after update (saving/closing etc...) if a checkbox is selected.
This is what I have so far. The code doesn't error but also doesn't send me an email?
----------------------
Private Sub Form_AfterUpdate()
If Engineer_Callback_Requried = "True" Then
'******begin code******
Dim email, subject1, Title, Customer, Company, mobilenumber, openedby, Description As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**gathers information from your form. this sets the string variable to your fields
email = "my@email.com"
subject1 = "Engineer Callback Required"
Title = Me!Title
Customer = Me!Customer
Company = Me!Company
mobilenumber = Me!Mobile_Phone
openedby = Me!Opened_By
Description = Me!Description
'***creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'***creates and sends email
With objEmail
.To = email
.subject = subject1 & " " & Title & " "
.Body = Customer & " " & Company & " "
.Body = mobilenumber & " "
.Body = openedby & " "
.Body = Description & " "
.Send
End With
'**closes outlook
Set objEmail = Nothing
objOutlook.Quit
End If
End Sub
--------------------
If I run this from a button taking the if statement out then it works ok.
What am I missing? Is this even possible?