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! - Option Compare Database
-
Option Explicit
-
-
Private Sub cmdSendAll_Click()
-
-
Dim rsAccountNumber As DAO.Recordset
-
Dim strTo As Variant
-
Dim strSubject As String
-
Dim strMessageText As String
-
-
Set rsAccountNumber = CurrentDb.OpenRecordset("SELECT DISTINCT EmployeeID, [email] FROM [queAutoUpdate]", dbOpenSnapshot)
-
-
Debug.Print strTo
-
-
With rsAccountNumber
-
-
Do Until .EOF
-
-
DoCmd.OpenReport "test", _
-
acViewPreview, _
-
WhereCondition:="EmployeeID = '" & !EmployeeID & "'", _
-
WindowMode:=acHidden
-
-
strTo = ![email]
-
strSubject = "Updated Balance "
-
strMessageText = "Text Here"
-
-
-
DoCmd.SendObject ObjectType:=acSendReport, _
-
ObjectName:="test", _
-
OutputFormat:=acFormatPDF, _
-
To:=strTo, _
-
Subject:=strSubject, _
-
MESSAGETEXT:=strMessageText, _
-
EditMessage:=True
-
-
-
DoCmd.Close acReport, "test", acSaveNo
-
-
-
.MoveNext
-
-
Loop
-
-
.Close
-
-
End With
-
End Sub
5 2043
It's only a guess, but if EmployeeID is a long number (or AutoNumber which is also a long number), line 21 should read - WhereCondition:="EmployeeID = " & !EmployeeID, _
The single quotes would only be used if EmployeeID were text.
Phil
Thanks Phil
Unfortunately EmployeeID is a text
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.
twinnyfo
Thanks for the reply! Someone informed me to change - DoCmd.Close acReport, "test", acSaveNo.
and
And it works! Yay!
Thank you for your time.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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 ...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |