This code sends an email using Outlook. The email is in the text box called "CompanyEmail" This works fine when there is an email in that textbox but gives me an runtime error 94 "Invalid use of null" when the field is empty.
Any help would be appreciated.
Any help would be appreciated.
Code:
Private Sub cmdSendemailWork_Click()
If Not IsNull(CompanyEmail) Then
Dim strEmail As String
'**create variables for Outlook
Dim objOutlook As Object
Dim objEmail As Object
'**gathers information from your form. this sets the string variable to your fields
strEmail = Me!CompanyEmail
'***creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.Application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'***creates and Displays email
With objEmail
.To = strEmail
.Display
End With
Exit Sub
End If