Option Compare Database
Option Explicit
Dim OkToSend As Boolean
Private Sub cboNewProcessID_AfterUpdate()
Me.NewProcessOwner.Value = cboNewProcessID.Column(2)
End Sub
Private Sub cmdSend_Click()
On Error GoTo Err_cmdSend_Click
OkToSend = CheckForNulls(Me)
If OkToSend = False Then
If IsNull(Me.ReviewNotes) Then
Me!ReviewNotes = Format(Date, "Medium Date") & ": Process reassigned from " & Me.cboProcessIDCurrent.Column(1) & " by " & cboProcessIDCurrent.Column(2) & " -- " & Me.ReassignNotes
Else
Me!ReviewNotes = Me.ReviewNotes & Chr(10) & Chr(10) & Format(Date, "Medium Date") & ": Process reassigned from " & cboProcessIDCurrent.Column(1) & " by " & cboProcessIDCurrent.Column(2) & " -- " & Me.ReassignNotes
End If
Me!StatusID = 1
Me.ProcessID = Me.cboNewProcessID
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.RunCommand acCmdSaveRecord
MsgBox "The CAR system is going to automatically send an email. Microsoft security features may generate a message that says..." & Chr(13) & Chr(13) & _
" 'A program is trying to automatically send email on your behalf. Do you want to allow this?'" & Chr(13) & Chr(13) & _
"If you receive this message, please click YES to allow the program to proceed.", vbInformation, "Processing..."
Dim OriginatorAddress As String
OriginatorAddress = DLookup("[Email]", "qryEmployees", "[EmployeeID]=" & Forms![Review frm]!OriginatorID)
Dim OriginatorName As String
OriginatorName = DLookup("[FullName]", "qryEmployees", "[EmployeeID]=" & Forms![Review frm]!OriginatorID)
Dim ProcessOwnerAddress As String
ProcessOwnerAddress = cboNewProcessID.Column(3)
SubjectLine = "New Corrective Action Request (CAR) " & [CARNum] & " for your review"
MailList = ProcessOwnerAddress
MyBodyText = "CAR " & [CARNum] & " has been opened against one of your processes. Please open the LMUK STS Corrective & Preventive Action System program from your desktop to review the CAR at your earliest convenience." & _
Chr(13) & Chr(13) & "DATE OPENED: " & Format([DateOpened], "Long Date") & _
Chr(13) & Chr(13) & "ORIGINATOR/EMAIL: " & Me.cboOriginatorID.Column(2) & _
Chr(13) & Chr(13) & "CAR TITLE: " & Me.Title & _
Chr(13) & Chr(13) & "PROCESS: " & Me.cboProcessID.Column(1) & _
Chr(13) & Chr(13) & "PROBLEM: " & Me.Description & _
Chr(13) & Chr(13) & "SOLUTION: " & Me.Solution
DoCmd.RunMacro "SendMail"
DoCmd.Close acForm, Me.Name
DoCmd.Close acForm, "Review frm"
End If
Exit_cmdSend_Click:
Exit Sub
Err_cmdSend_Click:
MsgBox "There was a problem emailing this CAR. Status has been reset to Requested." & Chr(13) & Chr(13) & _
"Please try again. If you continue to have problems, use the Feedback option" & Chr(13) & Chr(13) & _
"on the Main Menu to notify the Quality Administrator.", vbCritical, "Error"
Resume Exit_cmdSend_Click
End Sub