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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add an If then else to this code

Status
Not open for further replies.

T8JGT

IS-IT--Management
Feb 2, 2005
19
0
0
GB
Hi

I am a bit new to all this, so bare with me.

I have this piece of VBA which sends and email in HTML format. What i want to is if ITSQFList has text then add the statement "with the following points to note" after ITSQFQualityGate. If it is empty then there is no statement.

Any suggestions will be greatly appreciated.

CODE GIVEN BELOW.

Private Sub cmdSend_Click()
Dim strEmail, HTML As String
Dim objOutlook As Object
Dim objEmail As Object

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

strEmail = txtEmail
HTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & NL
HTML = HTML & "<html>"
HTML = HTML & "<body bgcolor=""#FFFFFF"">"
HTML = HTML & "<P><font size=""3"" face=""Optima"">"
HTML = HTML & ITSQFDocumentName & " received from " & ProjectServiceDesigner & _
":" & "<Strong>" & " '" & ProjectName & "'" & "</Strong>" & "- PAR " & ProjectPAR & Chr(13) & Chr(13) & "<BR>"
HTML = HTML & "Go Live - " & ProjectLiveDate & Chr(13) & "<BR></P>"
HTML = HTML & "<P>" & ProjectSummary & Chr(13) & "<BR> </P>"
HTML = HTML & "<P>" & ITSQFServRecommendation & Chr(13)
HTML = HTML & ITSQFQualityGate & Chr(13) & "<BR>"
HTML = HTML & ITSQFList & Chr(13) & "<BR> </P>"
HTML = HTML & "</body>"
HTML = HTML & "</html>"
objEmail.HTMLBody = HTML

'***creates and sends email
With objEmail
.To = ITSQFEmail
.Subject = "ITSQF Submission"
.HTMLBody = HTML
.Attachments.Add (ITSQFDocumentAddress)
.Send
End With


Set objEmail = Nothing

DoCmd.Close
 
T8JGT place this after ITSQFQualityGate
Code:
if len(trim(ITSQFList)>0) then 
    HTML = HTML & "with the following points to note" & Chr(13) & "<BR>"
end if
 
Try:
Code:
HTML = HTML & ITSQFQualityGate & Chr(13) & "<BR>"
If Not IsNull(ITSQFList) then HTML = HTML & "with the following points to note" & Chr(13
) & "<BR>" 'all on one line
HTML = HTML & ITSQFList & Chr(13) & "<BR> </P>"
Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
Many thanks

All working fine.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top