Checkboxes in Email

  • Thread starter jmh via AccessMonster.com
  • Start date
J

jmh via AccessMonster.com

I have an OnClick button that when clicked will send an email. The
txtProducts1-5 are the different products that will appear on the email. The
txtProducts1-5 are combo boxes. Is there a way that I could make these
checkboxes instead of combo boxes? In other words, I would want five
checkboxes (ckProducts1-5). If ckProducts1 is checked, then in the email I
want to put the actual product, which for ckProducts1 would be “Grapes”. Is
there a way to do this?

Also, I am going to need additional help as I have a lot to do with this code,
I thought I would do this in steps. So bear with me and I appreciate any
help I can get.

Here’s my code:


Private Sub Command45_Click()
'Takes the contents of the fields and put them into variables.
Client = Form.Client
'txtBody = Form.txtBody
txtProducts1 = Form.txtProducts1
txtProducts2 = Form.txtProducts2
txtProducts3 = Form.txtProducts3
txtProducts4 = Form.txtProducts4
txtProducts5 = Form.txtProducts5
'txtbody2 = Form.txtbody2
'txtforceline = Form.forceline
txtMainAddresses = Form.txtMainAddresses
txtCC = Form.txtCC


'Build the body of the E-mail
bodytext = bodytext & "I'm the Vice President of Products" + Chr(13) + Chr(13)

bodytext = bodytext & txtProducts1 + Chr(13) + Chr(13)
bodytext = bodytext & txtProducts2 + Chr(13) + Chr(13)
bodytext = bodytext & txtProducts3 + Chr(13) + Chr(13)
bodytext = bodytext & txtProducts4 + Chr(13) + Chr(13)
bodytext = bodytext & txtProducts5 + Chr(13) + Chr(13)
bodytext = bodytext & "We are honored that you allow us to serve you." + Chr
(13) + Chr(13)
bodytext = bodytext & "Thank you for letting us serve you." + Chr(13) + Chr
(13)
bodytext = bodytext & "http://yahoo.com/" + Chr(13) + Chr(13)
bodytext = bodytext & "Signee Name" + Chr(13)
bodytext = bodytext & "Signee Title"

Dim objOutlook As Object
Dim objmailItem As Object

'Create the Outlook object
Set objOutlook = CreateObject("Outlook.Application")

'Access a new mail item
Set objmailItem = objOutlook.CreateItem(olmailItem)

'Do things with the E-mail
With objmailItem
..To = txtMainAddresses
..cc = txtCC
..subject = "Welcome to Our Company"
..Body = bodytext
..display 'Use .Send if you want the message sent instead of display
End With


Set objmailItem = Nothing
Set objOutlook = Nothing


End Sub
 
J

jmh via AccessMonster.com

I got the below code to work by putting in the code for the AfterUpdate on
the checkboxes. The problem I am having now is that I want if txtproducts1
is null, then I don't want empty lines. What is happening is that if I click
ckproducts2, it will leave a blank line. How do I not have the empty lines?
 
R

RuralGuy

I believe you simply need to test for that situation:
If Not IsNull(txtProducts1) Then
bodytext = bodytext & txtProducts1 + Chr(13) + Chr(13)
End If
If Not IsNull(txtProducts2) Then
bodytext = bodytext & txtProducts2 + Chr(13) + Chr(13)
End If
If Not IsNull(txtProducts3) Then
bodytext = bodytext & txtProducts3 + Chr(13) + Chr(13)
End If
If Not IsNull(txtProducts4) Then
bodytext = bodytext & txtProducts4 + Chr(13) + Chr(13)
End If
If Not IsNull(txtProducts5) Then
bodytext = bodytext & txtProducts5 + Chr(13) + Chr(13)
End If


I got the below code to work by putting in the code for the AfterUpdate on
the checkboxes. The problem I am having now is that I want if txtproducts1
is null, then I don't want empty lines. What is happening is that if I click
ckproducts2, it will leave a blank line. How do I not have the empty lines?

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top