There is a way to do it but it takes a little bit of code and Outlook. The trick is, on the click event of the email button you have to declare a new outlook application, then attach the report of the form you're using to the email message. The "FindX" variable should be set equal to the number of the record that you're wanting to email. To do this, set FindX = to record_number. The only variable names you should have to change in this code is record_number and report_name. Note* you must have Outlook open to have this procedure work.
DoCmd.RunCommand acCmdRefresh
Dim pstrEmailName As String
Dim pstrComment As String
Dim pstrccName As String
Dim FindX
Dim strFileName As String
Dim strErrMsg As String
Dim olApp As New Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim strWhere As String
Set olNameSpace = olApp.GetNamespace("MAPI"
Set olMail = olApp.CreateItem(olMailItem)
FindX = record_number
strFileName = a file location to send the email
strWhere = "record_number=" & FindX
DoCmd.OpenReport "report_name", acViewPreview, , strWhere
DoCmd.OutputTo acOutputReport, "report_name", acFormatRTF, strFileName, False
DoCmd.Close
pstrEmailName = InputBox("Please enter your email destination", "Email"
pstrccName = InputBox("Enter CC address", "CC"
pstrComment = InputBox("Enter comments for your email", "Comments"
With olMail
.To = pstrEmailName
.CC = pstrccName
.Subject = "Incident Report #" & Case__
.Body = pstrComment
.Attachments.Add strFileName
.ReadReceiptRequested = False
.Send
End With
Kill strFileName
MsgBox "Request has been E-Mailed"
I have an alternate solution. Why not simply save your form as a report. Filter the report to be executed only for the current form record (Normally do this with a [forms]![forname]![fieldname] criteria) and then add a command button to your form which does a sendobject macro. The sendobject will open your email and execute your report at same time.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.