Change HTML Text on e-mail if checkbox selected. (1 Viewer)

totalnovice2

Registered User.
Local time
Today, 07:08
Joined
May 21, 2013
Messages
36
Hi.

I have the following code which works perfectly BUT I want to be able to add another line of text if users enable a checkbox. I have tried everything I can think of but can't get it to work. When using an "IF check150" statement it just adds the extra text in regardless of selection or not.

Code:
Function Mail_Radio_Outlook6(activedoc As String)
 Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Dim acc_req As String
    
    
    
       Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    
  
    strbody = "Hello.<br> <br> Please Find attached request for access. <br>"
              
   acc_req = "Orange / T-Mobile" & "  " & [Forms]![Front Page]![Text98].Value & "  " & " " & Forms![Front Page]![Site 2 Name].Value
   
    With OutMail
      On Error Resume Next
      
        .Display
        .To = [EMAIL="example@example.com"]example@example.com[/EMAIL]
        .CC = ""
        .Subject = acc_req
        .Attachments.Add (activedoc)
        .HTMLBody = strbody & "<br>" & .HTMLBody
        .Display
        
End With

End Function

This is fine most of the time but

If a user ticks check150 I want to add another paragraph.

Do I use an IF statement, if so in what format? is it a separate function etc?

I am slowly getting more familiar with Access but still come unstuck on the simplest of things at times.
 

pr2-eugin

Super Moderator
Local time
Today, 07:08
Joined
Nov 30, 2011
Messages
8,494
Just a simple IF.
Code:
Function Mail_Radio_Outlook6(activedoc As String)
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Dim acc_req As String
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    
    strbody = "Hello.<br> <br> Please Find attached request for access. <br>"
    
    [COLOR=Red][B]If [Forms]![Front Page]![check150] Then strbody = strbody & "Whatever you want to add"[/B][/COLOR]
    
    acc_req = "Orange / T-Mobile" & "  " & [Forms]![Front Page]![Text98].Value & "  " & " " & Forms![Front Page]![Site 2 Name].Value
   
    With OutMail      
        .Display
        .To = example@example.com
        .CC = ""
        .Subject = acc_req
        .Attachments.Add (activedoc)
        .HTMLBody = strbody & "<br>" & .HTMLBody
        .Display
    End With
End Function
 

totalnovice2

Registered User.
Local time
Today, 07:08
Joined
May 21, 2013
Messages
36
Thank you for the reply.

I was so close but was using "IF check150.enabled" or "IF check150.checked" THEN..

Yours works perfectly.

Thanks again.
 

Users who are viewing this thread

Top Bottom