I have a code that I am working with that is really neat, and works great. I just don know how to get rid of Error.number 94. I want the code to be able to ignore a field if it is null. Here is the code I am working with:
I am having troubles with the Command101_Err. I what have thus far, cuts part of the string when it is place on a new email message.
Thank you in advance!!!
Air.
Private Sub Command101_Click()
On Error GoTo Command101_Err
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application"
Set objEmail = objOutlook.CreateItem(olMailItem)
'*create string with email address
strEmail = LMPers
strBody = strBody & "ATTN: " & UCase(CStr(Forms!WWRDataEntry!ATTN)) & " " & Chr(13) & Chr(13)
strBody = strBody & "Your station has been affected by a World Wide Review of IID " & IID1 & ", " & UCase(CStr(Forms!WWRDataEntry!FleetType)) & ", " & UCase(CStr(Forms!WWRDataEntry!Nomenclature)) & " , which includes P/N(s) " & UCase(CStr(Forms!WWRDataEntry!PN)) & ". The following allocations changes have occured:" & Chr(13) & Chr(13)
strBody = strBody & "**DEALLOCATIONS: " & UCase(CStr(Forms!WWRDataEntry!GTWY1)) & " - Due to: " & UCase(CStr(Forms!WWRDataEntry!DeAllocationReason)) & " (Please return SV CPW)" & Chr(13) & Chr(13)
strBody = strBody & "**OVERALLOCATIONS: " & UCase(CStr(Forms!WWRDataEntry!GTWY2)) & " (Please return SV CPW)" & Chr(13) & Chr(13)
strBody = strBody & "**NEW ALLOCATIONS: " & UCase(CStr(Forms!WWRDataEntry!GTWY3)) & " (Please be advised)" & Chr(13) & Chr(13)
strBody = strBody & "**WORLDWIDE ALLOCATIONS: " & UCase(CStr(Forms!WWRDataEntry!TotalAllocations)) & " - Backorders will occur until all de-allocated/over-allocated and/or newly purchased units are recieved. Please FWD this to any interested parties." & Chr(13) & Chr(13)
strBody = strBody & "**SUMMARY: This is a " & UCase(CStr(Forms!WWRDataEntry!Summary)) & ". The current worldwide allocation investment for IID " & IID1 & " is " & TotalCost & ". We feel that these changes will provide the most complete coverage by maintaining the best possible utilization of our inventory assest." & Chr(13) & Chr(13)
strBody = strBody & "**CONTACT: Feel free to contact LMP via email address " & UCase(CStr(Forms!WWRDataEntry!emailcontact)) & " atlas 5-350-" & ATLAS & " and/or 502 - " & PHONE & " with any questions or concerns. Thank you for your cooperation with all material movements." & Chr(13) & Chr(13)
strBody = strBody & "Regards," & Chr(13) & Chr(13)
'***creates email
With objEmail
.TO = strEmail
.Subject = "WWR P/N " & PN & " " & UCase(CStr(Forms!WWRDataEntry!Nomenclature)) & ""
.Body = strBody
.Display
End With
Command101_Err:
'If a field on the form is empty - continue.
If strBody = strBody & Null Then
strBody = ""
Resume Next
End If
Set objEmail = Nothing
Exit Sub
End Sub
I am having troubles with the Command101_Err. I what have thus far, cuts part of the string when it is place on a new email message.
Thank you in advance!!!
Air.
Private Sub Command101_Click()
On Error GoTo Command101_Err
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application"
Set objEmail = objOutlook.CreateItem(olMailItem)
'*create string with email address
strEmail = LMPers
strBody = strBody & "ATTN: " & UCase(CStr(Forms!WWRDataEntry!ATTN)) & " " & Chr(13) & Chr(13)
strBody = strBody & "Your station has been affected by a World Wide Review of IID " & IID1 & ", " & UCase(CStr(Forms!WWRDataEntry!FleetType)) & ", " & UCase(CStr(Forms!WWRDataEntry!Nomenclature)) & " , which includes P/N(s) " & UCase(CStr(Forms!WWRDataEntry!PN)) & ". The following allocations changes have occured:" & Chr(13) & Chr(13)
strBody = strBody & "**DEALLOCATIONS: " & UCase(CStr(Forms!WWRDataEntry!GTWY1)) & " - Due to: " & UCase(CStr(Forms!WWRDataEntry!DeAllocationReason)) & " (Please return SV CPW)" & Chr(13) & Chr(13)
strBody = strBody & "**OVERALLOCATIONS: " & UCase(CStr(Forms!WWRDataEntry!GTWY2)) & " (Please return SV CPW)" & Chr(13) & Chr(13)
strBody = strBody & "**NEW ALLOCATIONS: " & UCase(CStr(Forms!WWRDataEntry!GTWY3)) & " (Please be advised)" & Chr(13) & Chr(13)
strBody = strBody & "**WORLDWIDE ALLOCATIONS: " & UCase(CStr(Forms!WWRDataEntry!TotalAllocations)) & " - Backorders will occur until all de-allocated/over-allocated and/or newly purchased units are recieved. Please FWD this to any interested parties." & Chr(13) & Chr(13)
strBody = strBody & "**SUMMARY: This is a " & UCase(CStr(Forms!WWRDataEntry!Summary)) & ". The current worldwide allocation investment for IID " & IID1 & " is " & TotalCost & ". We feel that these changes will provide the most complete coverage by maintaining the best possible utilization of our inventory assest." & Chr(13) & Chr(13)
strBody = strBody & "**CONTACT: Feel free to contact LMP via email address " & UCase(CStr(Forms!WWRDataEntry!emailcontact)) & " atlas 5-350-" & ATLAS & " and/or 502 - " & PHONE & " with any questions or concerns. Thank you for your cooperation with all material movements." & Chr(13) & Chr(13)
strBody = strBody & "Regards," & Chr(13) & Chr(13)
'***creates email
With objEmail
.TO = strEmail
.Subject = "WWR P/N " & PN & " " & UCase(CStr(Forms!WWRDataEntry!Nomenclature)) & ""
.Body = strBody
.Display
End With
Command101_Err:
'If a field on the form is empty - continue.
If strBody = strBody & Null Then
strBody = ""
Resume Next
End If
Set objEmail = Nothing
Exit Sub
End Sub