If statement to send email?

jas1159

Registered User.
Local time
Today, 00:59
Joined
Jun 13, 2011
Messages
11
I am using the following code to send an email from a form.

Code:
Private Sub Label133_Click()
Form_frmClose.SetFocus
Form_frmClose.txtEmail.SetFocus
On Error Resume Next
DoCmd.SendObject acSendForm, "frmClose", "html", Forms!frmClose.txtEmail, Forms!frmClose.txtEmail & "; " & Forms!frmClose.txtOriginatorEmail, , " 1111" & "_" & Forms!frmClose.txtName & "_" & Forms!frmClose.DatabaseStatus & "_" & Forms!frmClose.DatabaseReferenceNumber, "Dear 1111," & vbCr & " " & vbCr & "111111"
End Sub

Is it possible to send this email based on an IF statement?

E.g

If tickbox1 = ticked run the above code
If tickbox2 = ticked run similar code
If tickbox3 = ticked run similar code

I am sure it is possible, an indication on how would be greatly appreciated

Thanks
Jason
 
Jason,

Do you want this to happen when you click a checkbox or from a command button after you click the checkbox or for each checkbox that is true?
 
I would like to have 3 tick boxs only one of them will ever be ticked at once for example;

1) Version 1 required
2) Version 2 required
3) Version 3 required

And then to have a command button where when clicked it sends one of 3 pre scripted emails dependant on which check box has been ticked.

Thanks again
 
Try this out, add a command button to your form, then open the properties of the button and select Events and On Click, go into the code screen and paste this in: (Change checkbox names accordingly)
If Me.checkbox1 = True Then
Form_frmClose.SetFocus
Form_frmClose.txtEmail.SetFocus
On Error Resume Next
DoCmd.SendObject acSendForm, "frmClose", "html", Forms!frmClose.txtEmail, Forms!frmClose.txtEmail & "; " & Forms!frmClose.txtOriginatorEmail, , " 1111" & "_" & Forms!frmClose.txtName & "_" & Forms!frmClose.DatabaseStatus & "_" & Forms!frmClose.DatabaseReferenceNumber, "Dear 1111," & vbCr & " " & vbCr & "111111"
ElseIf Me.checkbox2 = True Then
Form_frmClose.SetFocus
Form_frmClose.txtEmail.SetFocus
On Error Resume Next
DoCmd.SendObject acSendForm, "frmClose", "html", Forms!frmClose.txtEmail, Forms!frmClose.txtEmail & "; " & Forms!frmClose.txtOriginatorEmail, , " 1111" & "_" & Forms!frmClose.txtName & "_" & Forms!frmClose.DatabaseStatus & "_" & Forms!frmClose.DatabaseReferenceNumber, "Dear 1111," & vbCr & " " & vbCr & "111111"
ElseIf Me.checkbox3 = True Then
Form_frmClose.SetFocus
Form_frmClose.txtEmail.SetFocus
On Error Resume Next
DoCmd.SendObject acSendForm, "frmClose", "html", Forms!frmClose.txtEmail, Forms!frmClose.txtEmail & "; " & Forms!frmClose.txtOriginatorEmail, , " 1111" & "_" & Forms!frmClose.txtName & "_" & Forms!frmClose.DatabaseStatus & "_" & Forms!frmClose.DatabaseReferenceNumber, "Dear 1111," & vbCr & " " & vbCr & "111111"
Else
MsgBox "No checkbox has been selected"

End If
 

Users who are viewing this thread

Back
Top Bottom