Gents,
This is what I have now:
Code:
Public Sub SendOOB_Click()
On Error GoTo ErrorMsgs
Set rs = CurrentDb.OpenRecordset("SELECT OOBNumber, Priority FROM qRecSourceOOBChanges Order by [Level], CRID ASC")
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
strHdrMail = "This is a follow-on action from the AORB/CCB/TEWG discussion on CR" & OOBNumber & ". If needed, please back-brief your O6 for SA, " _
& "and let us know if there are any issues or concerns. The Change Request priority is " & Priority & " with " & Hr & "hours until" _
& "CR" & OOBNumber & " is automatically approved (GO OOB Excepeted). Please provide your votes NLT " & DTG & "." & vbCrLf & vbCrLf
'While Not rs.EOF
'strBdyMail = "Date Issue Identified: " & Chr(9) & Chr(9) & !Dates & vbCrLf & vbCrLf" _
' & "Priority: " & Chr(9) & Chr(9) & Chr(9) & !Priority & vbCrLf _
' & "CR Number: " & Chr(9) & Chr(9) & Chr(9) & !OOBNumber & vbCrLf _
' & "AO Recommendation: " & Chr(9) & Chr(9) & !AOVote & vbCrLf & vbCrLf _
' & "Change Requested: " & Chr(9) & Chr(9) & ![ChangeRequested] & vbCrLf & vbCrLf _
' & "Unit & Section: " & Chr(9) & Chr(9) & !Units & vbCrLf _
' & "MTOE Para & Bumper Number: " & Chr(9) & ![MTOEParas] & vbCrLf & vbCrLf _
' & "Rationale: " & Chr(9) & Chr(9) & !Rationale & vbCrLf & vbCrLf _
' & "Notes: " & Chr(9) & Chr(9) & Chr(9) & !NOTES & vbCrLf _
' & "Action Items: " & Chr(9) & Chr(9) & !ActionItems & vbCrLf & vbCrLf
' rs.MoveNext
'Wend
' rs.Close
With objOutlookMsg
.Subject = NIE & " - " & Label & " - " & Tod
.Body = strHdrMail & strBdyMail & SigBlock
DoCmd.OutputTo 3, "rptOOB", acFormatPDF, "C:\Temp\" & NIE & " - " & Label & " - " & Tod & ".pdf", , 0
.Attachments.Add ("C:\Temp\" & NIE & " - " & Label & " - " & Tod & ".pdf")
.To = ""
.Display
Kill "C:\Temp\" & NIE & " - " & Label & " - " & Tod & ".pdf"
DoCmd.Close acForm, "frmOOBChangeSelect"
DoCmd.Close acReport, "rptOOB"
DoCmd.OpenForm "frmStart"
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookAttach = Nothing
Exit Sub
ErrorMsgs:
If Err.Number = "287" Then
MsgBox "You selected No to the Outlook security warning. Rerun the procedure and click Yes to access e-mail addresses to send your message."
Else
MsgBox Err.Number & " " & Err.Description
End If
End Sub
I now get an error 2465 Can't finf the field 'Priority' referred to in your expression. Ihave tried Priority1: IIf(IsNull([Priority]),'Medium',[Priority]) in case. Still the same error. Can't find it. I have looked at the differences in the control spelling. All appear to be the same.
Code:
Sub subCreateQuery(arg)
Dim sSQL As String
Select Case arg
Case 1
sSQL = "SELECT [CRNo]+([SubNo]*0.01) AS OOBNumber, Priority, IIf(IsNull([Priority]),'Medium',[Priority]) AS Priority1, CRID, [Level], NIE, ChangeType, DateID, " _
& "ChangeRequested, Rationale, NOTES, ActionItems, AOVote, O6Vote, Hr, " _
& "Format([DateID],'dddd'', ''mmm d yyyy') AS Dates, " _
& "Format(Now()+([Hr]/24),'hhnn dddd'', ''mmm d yyyy') AS [Time], " _
& "Format(Now()+([Hr]/24),'hhnn dddd'', ''mmm d yyyy') AS DTG, [Unit] & Chr(13) & Chr(10) & " _
& "[Section] AS Units, [HBVersion] & Chr(13) & Chr(10) & [ApproxPage] AS HBVers, " _
& "[MTOEPara] & Chr(13) & Chr(10) & [BumperNum] AS MTOEParas, " _
& "[Requestor] & Chr(13) & Chr(10) & [Sponsor] AS People, " _
& "DateDiff('d',[DateID],[DateClosed]) AS DaysOpen, [Priority] & ' ' & [Level] & ' OOB Change Request' AS Label " _
& "FROM TblChangeRequest " _
& "WHERE (([ActionComplete])=False) AND (([AOVote])" & TempVars!AOSelects & " AND (O6Vote) " & TempVars!O6Selects & " and(([CRNo])<>0) AND (([HR])=0));"
Call fcnCustomizeSQL("qRecSourceOOBChanges", sSQL)
Case 2
Case 3
End Select
End Sub