Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Emailing Form after update if check box it ticked!?

Status
Not open for further replies.

mdex

Technical User
Nov 28, 2011
10
GB
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?
 
take the quotes off of True in the if statement

HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work
 
If you set a checkpoint in your code and step through it, I think you'll find that Engineer_Callback_Requried is NEVER equal to "True". True/False is boolean.


Randy
 
Ok, so what value do checkboxes return?

will I need to use 1/0 rather than true/false?

Sorry, I'm not with my database at the moment to play with it.

Thanks for all the help.
 
Use the value suggested by MazeWorX (TRUE without quotes).
Or, simply this...
Code:
If Engineer_Callback_Requried Then


Randy
 
remove the quotes

Code:
If Engineer_Callback_Requried = [highlight]"[/highlight]True[highlight]"[/highlight] Then

HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work
 
Sorry I thought you Randy meant it would never be true or false regardless of quotes.

Works fine cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top