in my application send mail, on click of a button "Attachments" we can attach any file

and on click of button "sendmail" we can send the mail.

but if we dont attach any file and click send mail
error is thrown. invalid use of null.

code for attachment button is


Private Sub cmdAttachment_Click()
Dim intReturn As Integer, strarray() As String
If IsNull(txtAttachment) Then
txtAttachment = ahtCommonFileOpenSave(, "C:\", , , "pdf", _
, "Select file to attach")
Else
txtAttachment = txtAttachment & "; " & ahtCommonFileOpenSave(, "C:\", , _
, "pdf", , "Select file to attach")
End If
intReturn = SplitVB5(txtAttachment, "/", strarray)
strDisplayName = strarray(intReturn)
intReturn = SplitVB5(strDisplayName, ".", strarray)
strDisplayName = strarray(2)
txtAttachment.Visible = True
lblAttachment.Visible = True
cmdAttachment.Caption = "Add Another"

End Sub

and code for send button is


Private Sub cmdSend_Click()
On Error GoTo Whoops
'If txtBody <> "" Then
Dim objOL As Outlook.Application, msg As MailItem, objAttch As Object
Dim strAttachment As String, strarray() As String, intReturn As Integer, x As Integer
Set objOL = CreateObject("Outlook.Application")
Set msg = objOL.CreateItem(olMailItem)
strAttachment = txtAttachment
With msg
.To = txtTo
'If Not IsNull(txtCC) Then
.CC = txtCC
.Subject = txtSubject
.Body = txtBody
'End If
'If Not IsNull(strAttachment) Then
Set objAttch = .Attachments
intReturn = SplitVB5(strAttachment, "; ", strarray)
For x = 1 To intReturn
objAttch.Add Trim(strarray(x)), , 5000
Next
'End If
If chkDisplay Then
.Display
Else: .Send: MsgBox " Message sent!"
End If
End With
txtTo = Null
txtCC = Null
txtSubject = Null
txtBody = Null
chkDisplay = False
'txtAttachment = Null
'txtAttachment.Visible = False
'lblAttachment.Visible = False
cmdAttachment.Caption = "Add Attachment"
: MsgBox " All fields are required."
'End If
OffRamp:
On Error Resume Next
Set objOL = Nothing
Exit Sub
Whoops:
MsgBox "Error #" & ": " & Err.Description
Resume OffRamp
End Sub




karam