473,394 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Split MS-Access reports into separate emails

Hi,

I am trying to send separate Employees a PDF of their section/page of their report. The information is based on their EmployeeID. So each person has their balance information on a page then there's a page break, and then next page shows the next person's details. With the code below, it does email each of the employees one page but it so happens to only email the first person's page to EVERYONE. Is it possible to somehow automate so that each user is emailed his/her individual page of the report?

Another error is that the email pop up one by one so I have to press send each time for over 200 people, and that the email seems to be sending to the email but then followed by #mailto:the email# for example email@email.com#mailto:email@email.com#

I just started Access and have been copying and scraping code off of places I have found online. Many thanks in advance, if you can assist!

Have a great day!


Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub cmdSendAll_Click()
  5.  
  6. Dim rsAccountNumber As DAO.Recordset
  7. Dim strTo As Variant
  8. Dim strSubject As String
  9. Dim strMessageText As String
  10.  
  11. Set rsAccountNumber = CurrentDb.OpenRecordset("SELECT DISTINCT EmployeeID, [email] FROM [queAutoUpdate]", dbOpenSnapshot)
  12.  
  13. Debug.Print strTo
  14.  
  15. With rsAccountNumber
  16.  
  17. Do Until .EOF
  18.  
  19. DoCmd.OpenReport "test", _
  20. acViewPreview, _
  21. WhereCondition:="EmployeeID = '" & !EmployeeID & "'", _
  22. WindowMode:=acHidden
  23.  
  24. strTo = ![email]
  25. strSubject = "Updated Balance "
  26. strMessageText = "Text Here"
  27.  
  28.  
  29. DoCmd.SendObject ObjectType:=acSendReport, _
  30. ObjectName:="test", _
  31. OutputFormat:=acFormatPDF, _
  32. To:=strTo, _
  33. Subject:=strSubject, _
  34. MESSAGETEXT:=strMessageText, _
  35. EditMessage:=True
  36.  
  37.  
  38. DoCmd.Close acReport, "test", acSaveNo
  39.  
  40.  
  41. .MoveNext
  42.  
  43. Loop
  44.  
  45. .Close
  46.  
  47. End With
  48. End Sub
Feb 13 '19 #1
5 2043
PhilOfWalton
1,430 Expert 1GB
It's only a guess, but if EmployeeID is a long number (or AutoNumber which is also a long number), line 21 should read
Expand|Select|Wrap|Line Numbers
  1. WhereCondition:="EmployeeID = " & !EmployeeID, _
The single quotes would only be used if EmployeeID were text.

Phil
Feb 13 '19 #2
Thanks Phil

Unfortunately EmployeeID is a text
Feb 14 '19 #3
twinnyfo
3,653 Expert Mod 2GB
What you want to do cannot be done using either OpenReport or SendObject, due to the nature of how those functions work.

You must establish a public variable that you can refer to in order to filter the report as it is generated, then send the report. This has been done multiple times on this forum, and I am unable to find that particular post. I can try to address this later, as I am currently unable to sit and create the code for you.

I can check back later and work through this.
Feb 14 '19 #4
twinnyfo

Thanks for the reply! Someone informed me to change

Expand|Select|Wrap|Line Numbers
  1. DoCmd.Close acReport, "test", acSaveNo.
and
Expand|Select|Wrap|Line Numbers
  1. EditMessage:=False
And it works! Yay!

Thank you for your time.
Feb 15 '19 #5
twinnyfo
3,653 Expert Mod 2GB
I’m glad that you found a solution, even though I don’t see how it can work, since you are never saving the filtered report and you are not filtering the report you actually send. But if you are satisfied, so am I.
Feb 15 '19 #6

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

Similar topics

0
by: precious | last post by:
i'm trying to split my xml configuration file to files implementing the parsing using xerces in java (DOMparser). my project uses a "fromXML" parsing design and here's what i tried in the node...
7
by: SharkSYA | last post by:
After canvassing ideas it appears that the way I need to do it is not possible.There are 126 rooms, more to be added, and it needs to print a report or reports showing 76 days of bookings. There...
1
by: Bob Bedford | last post by:
Hello all, I've to send some reports to a mailing list. Those reports must be created by datas stored in mysql, using PHP. - my first idea is to create PDF files that can be sent by email or...
4
by: Stephen Poley | last post by:
Whenever anyone has a question about securing an Access database he/she is usually referred (unsurprisingly) to the Security FAQ. This is however incomplete/unclear with respect to databases with a...
1
by: John K. Humkey | last post by:
I'm at a loss (and, like a hard-core alcoholic) the "experts" I'm working with won't even acknowledge there is a problem. . . Is there any way to run "interactive transactions" at one priority...
4
by: PraveenKadkol | last post by:
Hi, My Development is in almost final stages, now i am facing problem with the reports. I am generating MsAccess Reports based on the selected Parameters, while generating Report I am opening ...
4
by: mikevde | last post by:
Hi, I have a query where I select all the values from my MS SQL table that are LIKE a certain string. The query works, but in the ASP page, I only want to write the date once, while writing the...
0
by: Michiel Overtoom | last post by:
Ahmed wrote... I'm not sure if you are able to bypass Outlook (and have Python fetch the mail itself using poplib), but if you are, the following code might be useful. I use this to pry apart...
5
by: Jason Hamilton | last post by:
Greetings all, So first post here, but it looks like an active, helpful community, so here goes. I am working with a client who wants to make his current MS Access 2007 Reports available on...
3
by: Steven Sargent | last post by:
I want to know if there is a way to use the split function to separate every single character. For example, if I input "Hello", the program will output H e l l o Every tutorial I've found...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.