Full Version: Send Command Button
UtterAccess Forums > Microsoft® Access > Access Forms
I have an email form with a command button call "Send" the code that I use are as follow but it gives me a compile error "Sub or Function not defined". Looks as if it has something to do in the code:
intReturn = SplitVB5(strAttachment, "; ", strarray)
Private Sub cmdSend_Click()
On Error GoTo Whoops
If txtTo <> "" And txtSubject <> "" And 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
If Not IsNull(strAttachment) Then
Set objAttch = .Attachments
intReturn = SplitVB5(strAttachment, "; ", strarray)
For X = 1 To intReturn
objAttch.Add Trim(strarray(X)), , 5000
End If
If chkDisplay Then
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"
Else: MsgBox " All fields are required."
End If
On Error Resume Next
Set objOL = Nothing
Exit Sub
MsgBox "Error #" & ": " & Err.Description
Resume OffRamp
End Sub
You do not have the SplitVB5 function defined anywhere in your code.
would check to see if you are missing a module or sub routine that defines the SplitVB5 function.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.