Neobeowulf
Registered User.
- Local time
- Today, 09:31
- Joined
- May 31, 2012
- Messages
- 34
Team,
I'm trying to figure out how to get access to filter a report based off my selection in a combo box before emailing.
So, when I pick "The boss" in my combo box then hit my email button, it would filter all my reports by whats with the boss then email it to him. I'm pretty sure I need to use Forms!Main.Namecmb, but i'm not sure how/where to put it in the code.
Lastly, .Send is not working at the end of the code. Suggestions?
I'm trying to figure out how to get access to filter a report based off my selection in a combo box before emailing.
So, when I pick "The boss" in my combo box then hit my email button, it would filter all my reports by whats with the boss then email it to him. I'm pretty sure I need to use Forms!Main.Namecmb, but i'm not sure how/where to put it in the code.
Lastly, .Send is not working at the end of the code. Suggestions?
Code:
Private Sub Command82_Click()
Dim strRep As String
Dim strDPath As String
Dim strFName As String
' What report to send
strRep = "Pending Reports"
' Initial Path
strDPath = "S:\CCEA\Dashboard\Daily EPR-OPR-DEC Slides/"
' Filename
strFName = "Evaluations.pdf"
' Output report as pdf
DoCmd.OutputTo acOutputReport, strRep, "PDFFormat(*.pdf)", strDPath & strFName, False, "", 0
' Send the report to whoever
Send_Email (strDPath & strFName)
End Sub
Private Sub Send_Email(strDoc As String)
Dim sTo As String
Dim sCC As String
Dim sBCC As String
Dim sSub As String
Dim sBody As String
Dim strCC As String
Dim OutApp As Object
Dim OutMail As Object
Dim varPress As Variant
' Get the email address from the current form control
sTo = "[EMAIL="Russell.Huffstetler@afcent.af.mil"]Email name[/EMAIL]"
' Set the subject
sSub = "Evaluations Report"
' Build the body of the email
sBody = "Sir," & vbCrLf & vbCrLf
sBody = sBody & "This is a test of my database email system. Hope it works!"
' Create the email
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
sCC = ""
sBCC = ""
With OutMail
.To = sTo
.CC = sCC
.BCC = sBCC
.Subject = sSub
.Body = sBody
.attachments.Add (strDoc)
.SEND
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub