At the moment I am using an unbound combobox to make a selection
Row Source: SELECT DISTINCT Field.[Field Name], Field.Field_ID FROM Field ORDER BY Field.Field_ID;
This then uses the below code to filter the fields, which sets it up for a text email.
Code:
[Private Sub Send_AORB_OOB_Click()
On Error GoTo Error
Dim strSubject, strBody, strAddresses As String
DoCmd.RunCommand acCmdSaveRecord
If IsNull(CR_Numbers) Then
MsgBox "There are no OOB CRs to send"
DoCmd.Close acForm, "Email_AORB"
Exit Sub
Else
With Me
If Not IsNull(.cbxNumber) And Not IsNull(.Priority) And Not IsNull(.Hours) Then
strBody = "Action Officers," & vbCrLf & "This is a follow-on from today's AORB/ERB discussion on CR " _
& !CR_Numbers & ". If needed, please back-brief your O6 for SA, and let me know if there are any issues or concerns. " _
& "The Change Request priority is " & !Priority & " with " & !Hr & " hours until CR is automatically approved. " _
& "Please provide your votes NLT " & !DTG & ". Please call if you have any questions or issues." & vbCrLf & vbCrLf & vbCrLf
strBody = strBody & "Date Issue Identified: " & Chr(9) & Chr(9) & Chr(9) & !Dates & vbCrLf & vbCrLf
strBody = strBody & "Priority: " & Chr(9) & Chr(9) & Chr(9) & Chr(9) & !Priority & vbCrLf
strBody = strBody & "CR Number: " & Chr(9) & Chr(9) & Chr(9) & Chr(9) & !CR_Numbers & vbCrLf
strBody = strBody & "Change Requested: " & Chr(9) & ![Change Requested] & vbCrLf & vbCrLf
strBody = strBody & "Unit & Section: " & Chr(9) & Chr(9) & Chr(9) & !UNITS & vbCrLf
strBody = strBody & "MTOE Para & Bumper Number: " & Chr(9) & ![MTOE Paras] & vbCrLf & vbCrLf
strBody = strBody & "Rationale: " & Chr(9) & Chr(9) & !Rationale & vbCrLf & vbCrLf
strBody = strBody & "Notes: " & Chr(9) & Chr(9) & Chr(9) & !NOTES & vbCrLf
strBody = strBody & "Action Items: " & Chr(9) & Chr(9) & !Action_Items & vbCrLf & vbCrLf & vbCrLf & vbCrLf
strBody = strBody & "V/R" & vbCrLf & vbCrLf
strBody = strBody & "Configuration Management" & vbCrLf
strBody = strBody & "Brigade Modernization Command (BMC)" & vbCrLf
strBody = strBody & "Network Integration Division (NID)" & vbCrLf
strBody = strBody & "BLDG 2, Sheridan Road" & vbCrLf
strBody = strBody & "Ft Bliss, TX 79916" & vbCrLf
strBody = strBody & "Person" & Chr(9) & "(915)569-5167" & Chr(9) & "Email Addy" & vbCrLf
strSubject = !Priority & " OOB AORB Change Request Number " & !CR_Numbers & " - " & ![Change Requested]
DoCmd.Close acForm, "Email_AORB"
DoCmd.SendObject acSendNoObject, , acFormatTXT, strAddresses, , , strSubject, strBody, True
End If
End With
Exit Sub
Error_Handler_Exit:
Exit Sub
Error:
Select Case Err.Number
Case 2501
Err.Clear
Resume Error_Handler_Exit
Case Else
MsgBox "Error No. " & Err.Number & vbCrLf & "Description: " & Err.Description, vbExclamation, "Database Error"
Err.Clear
Resume Error_Handler_Exit
End Select
Exit Sub
End If
am running this in VBA for the unbound combobox.
Private Sub cbxNumber_AfterUpdate()
Me.Filter = "CR_Numbers=" & Me.cbxNumber
Me.FilterOn = True
End Sub
How would I go about using a listbox where I can select multiple fields? I would like to send more than 1 CR per email. I think I would also need some kind of loop code in the email?