S
scott04
Hi everyone,
I am trying to have a button that onclick basically blanks out my form and
in turn outlook sends an email notification that a new record has been
created. One problem though when the user doesn't fill out the entire form
and my coded rules kick in to make a user fill in a field my email code still
fires. Can someone look at my code below and make some suggestions so the
email code doesn't fire unless no errors? Thanks
Private Sub Sub_Question_Click()
On Error GoTo Procerror
DoCmd.GoToRecord , , acNewRec
Dim strPath As String
Dim rst As DAO.Recordset
Dim AppOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set AppOutLook = CreateObject("Outlook.Application")
Set MailOutLook = AppOutLook.CreateItem(olMailItem)
Dim EContent As String
Dim stDocName As String
Me.Dirty = False
With MailOutLook
..To = "(e-mail address removed)"
..CC = "(e-mail address removed)"
..Subject = "Pending Request"
..Importance = olImportanceHigh
..Body = "You have a new ticket in the database"
..Save
..Send
End With
Procerror:
If Err.Number = 20 Or Err.Number = 0 Or Err.Number = 2105 Then
Resume Next
Else
MsgBox "Error " & Err.Number & ": " & Err.Description, , _
"Error in Click event procedure..."
I am trying to have a button that onclick basically blanks out my form and
in turn outlook sends an email notification that a new record has been
created. One problem though when the user doesn't fill out the entire form
and my coded rules kick in to make a user fill in a field my email code still
fires. Can someone look at my code below and make some suggestions so the
email code doesn't fire unless no errors? Thanks
Private Sub Sub_Question_Click()
On Error GoTo Procerror
DoCmd.GoToRecord , , acNewRec
Dim strPath As String
Dim rst As DAO.Recordset
Dim AppOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set AppOutLook = CreateObject("Outlook.Application")
Set MailOutLook = AppOutLook.CreateItem(olMailItem)
Dim EContent As String
Dim stDocName As String
Me.Dirty = False
With MailOutLook
..To = "(e-mail address removed)"
..CC = "(e-mail address removed)"
..Subject = "Pending Request"
..Importance = olImportanceHigh
..Body = "You have a new ticket in the database"
..Save
..Send
End With
Procerror:
If Err.Number = 20 Or Err.Number = 0 Or Err.Number = 2105 Then
Resume Next
Else
MsgBox "Error " & Err.Number & ": " & Err.Description, , _
"Error in Click event procedure..."