By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,057 Members | 1,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,057 IT Pros & Developers. It's quick & easy.

sending report via e-mail

P: 38
I have a salary report in between dates as I enter.
The filter I'm using for the dates is :
strWhere = strField & " Between " & Format(Me.txtStartDate, conDateFormat) _
& " And " & Format(Me.TxtEndDate, conDateFormat)
I'd like to send this filtered report through e-mail in rtf format or word.

My question is : how do I make sure that this filtered report, in the specific dates I entered is sent (or how do I use this date filter to send)?
Thanks.
Dec 23 '07 #1
Share this Question
Share on Google+
3 Replies


Jim Doherty
Expert 100+
P: 897
I have a salary report in between dates as I enter.
The filter I'm using for the dates is :

I'd like to send this filtered report through e-mail in rtf format or word.

My question is : how do I make sure that this filtered report, in the specific dates I entered is sent (or how do I use this date filter to send)?
Thanks.

Apply the same filtration to the report using your filtration criteria as part of the WHERE clause when opening the report and then send it outputted as an RTF attached document using DoCmd SendObject.

RTF's are too basic for my liking and 'can' lose much of the formatting you are able to give reports in Access. I prefer to send either as a snapshot file or as a PDF

Does this help you?

Jim :)
Dec 23 '07 #2

P: 38
I have a problem
When I press the report button on the form, I get another small form where I define the date parameter.
What I'm truying to do is to put another button on the small dorm when pressing it will lead to the report sent by e-mail.

I'm using this:
Dim stDocName As String
Dim strField As String 'Name of your date field.
Dim strWhere As String

stDocName = "RPT_SALARY_HOURS"
'DoCmd.SendObject acReport, stDocName, , strWhere
strField = "Date"

strWhere = strField & " Between " & Format(Me.txtStartDate, conDateFormat) _
& " And " & Format(Me.TxtEndDate, conDateFormat)


DoCmd.SendObject acReport, stDocName, , strWhere
The file is sent but the filter does not work (ut sends all the former dates, and not only what I want.

Help?
Thanks.
Dec 23 '07 #3

Jim Doherty
Expert 100+
P: 897
I have a problem
When I press the report button on the form, I get another small form where I define the date parameter.
What I'm truying to do is to put another button on the small dorm when pressing it will lead to the report sent by e-mail.

I'm using this:


The file is sent but the filter does not work (ut sends all the former dates, and not only what I want.

Help?
Thanks.
Set the filter property of the report to the relevant criteria string when the report opens.

Enter this into the on open event of the 'report' where the reference to frmHolidayDates entered here should be subsituted for the name of your form on which you have the dates from and to fields and the command button that sends the report by mail

Expand|Select|Wrap|Line Numbers
  1.  
  2.     Dim strField As String, strCriteria As String
  3.     conDateFormat = "mm/dd/yyyy"
  4.     strField = "[Date]"
  5.     strCriteria = strField & " Between " & "#" & Format(Forms!frmHolidayDates!txtDateFrom, conDateFormat) _
  6.                  & "# And #" & Format(Forms!frmHolidayDates!txtDateTo, conDateFormat) & "#"
  7. Me.filter = strCriteria
  8. Me.FilterOn = True
  9.  
On your form in the command button you use to send the report should be something merely like this

Expand|Select|Wrap|Line Numbers
  1.  
  2. DoCmd.SendObject acReport, "YourReportName", "RichTextFormat(*.rtf)", "someone@somewhere.com", "", "", "MyReport subject", "This is my emailbody", False, ""
  3.  
Now when the report opens it will look for your form to be 'open' take the relevant values from the forms date fields and apply them to the filtration of the report

The FALSE part of the send object command means you intend to edit the message before it it is sent. amending it to True means you do not mean to edit it...essentially send it straight away depending on the setting of your email client

Jim :)
Dec 23 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.