• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 673
  • Last Modified:

DoCmd.SendObject acSendReport: Send unique reports

Sample attached; sending report by email from form.
Problem: it sends the every report to every person.
Each person in "PaymentHistoryQryList" should get their report only.
Sample.mdb
0
ShawnGray
Asked:
ShawnGray
  • 3
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
shawngray,
you have to apply filter to your report, as you iterate to your recordset

the northwind sample database shows how this is done in the Orders form.
see the codes behind the Print invoice button click
0
 
ShawnGrayAuthor Commented:
Hey Capricorn1,
The NWind sample is filtering the report based on the current record on the form.
I may be missing something (won't be the first time) but if I'm attempting to send to each client only the data that relates to them, I don't want to go through hundreds of records one at a time.

Shawn

0
 
ShawnGrayAuthor Commented:
Hey Cap,
I've been looking at the NWind.Invoices structure.  
The code behind the print invoices uses a filter but the filter is based on the record that is currently opened in the form.  Applying that to my sample feels like a chicken and egg problem.  I need the Filter but the I can't apply the filter without an active record.

Sure could use a little more help on this.

Thanks,
Shawn
0
 
Rey Obrero (Capricorn1)Commented:
using the recordset,

  rs.MoveFirst    '<<< '** the first record now is the  active record
    Do Until rs.EOF

    'do the filtering here
     

    rs.MoveNext     '<<< the next record will become the active record
    Loop

is it clearer now?
0
 
ShawnGrayAuthor Commented:
Yes, thanks.
I was able to create my query structure like the example which contains the necessary filter.
Although I had to add a line in the code.  For some reason it was sending only the first report to each person.  

Not as clean as you would have done it but I think it'll get the job done.
If you don't see any problems with this I'll accept your last solution.

Thanks again,
Shawn
 rs.MoveFirst 
 Do Until rs.EOF
 DoCmd.SendObject acSendReport, "History", acFormatHTML, rs!Email, , , "Test sub", "test msg", , True
 
 DoCmd.GoToRecord , , acNext  '<<<Without this it was sending the first report only to each person
 
 rs.MoveNext 
 Loop

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now