473,404 Members | 2,174 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,404 software developers and data experts.

Email filtered report by Supplier from a list of email address in Supplier table

Here is an outline of my process:

1. I submit score cards to suppliers on a monthly basis.

2. I have a table with supplier names and email address. If the supplier is currently active the “Inactive” check box field in that record in not checked. Additional suppliers could be added at any time. Existing suppliers could become inactive then reactivated at a later date. Only active suppliers (those without the “Inactive” check-box field checked) should ever be listed.

3. I have a form with a combo box to filter and display the score card data in a subform for that selected supplier.

4. I use a VBA process that emails the filtered data to the supplier selected in the combo box. As there are numerous suppliers, I am looking to automate this process so I do not have to manually select suppliers individually and email them their individually filtered report.

I found some code online that enables me, with one-click, to send an email to individual suppliers using the email address as listed in my supplier table. The code allows me to add a subject line and message body for each supplier by name.

Here is what I now need:

1. I want to use VBA to filter the data for the report for each supplier within the supplier table.

2. Attach the filtered report to the email being sent to that supplier. Filter and email only the data for the selected supplier and not all data to all suppliers.

3. Loop this process for each active supplier in the supplier table; inactive check-box field is not checked in the supplier table.

I hope I explained this well enough to get some haelp.

Any assistance would be GREATLY appreciated!!

Here is the code I am currently working with:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOneClickMassEmail_Click()
  2. On Error GoTo ErrorMessage
  3. Set OutApp = CreateObject("Outlook.Application")
  4. Dim rs As DAO.Recordset
  5. Set rs = CurrentDb.OpenRecordset("_tmpSuppliers")
  6. Dim rp = CurrentReportingPeriod
  7. With rs
  8.  
  9.     If .EOF And .BOF Then
  10.     MsgBox "No emails will be sent becuase there are no records assigned from the list", vbInformation
  11.     Else
  12.     Do Until .EOF
  13.     stremail = ![SupplierToEmailAdderss]
  14.     stremailcc = ![SupplierCCEmailAdderss]
  15.     strsubject = "Score Card for " & ![SupplierName] & " - " & DLookup("[Current Period]", "[qrySelect_CurrentReportingPeriodMonthAndYear]", "[Current Period]")
  16.     strbody = "Dear " & ![SupplierName] & "," & vbCrLf & _
  17.               "Email message body goes here."
  18.     Set OutMail = OutApp.CreateItem(olMailItem)
  19.     With OutMail
  20.     .To = stremail
  21.     .CC = stremailcc
  22.     .BCC = ""
  23.     .Subject = strsubject
  24.     .Body = strbody
  25.     .Send
  26.     End With
  27.     .MoveNext
  28.     Loop
  29.     End If
  30. End With
  31. Exit_cmdOneClickMassEmail_Click:
  32. Exit Sub
  33. ErrorMessage:
  34.     MsgBox Err.Description
  35.     Resume Exit_cmdOneClickMassEmail_Click
  36. End Sub
  37.  
Apr 3 '14 #1
1 1649
jimatqsi
1,271 Expert 1GB
Chip,
I do this routinely every day. However, I don't use Outlook because it requires a response to a security pop-up every time an email is sent. It's possible the later versions of Outlook don't require that. I use CDO email instead. You can learn all you need to know about CDO email by searching the web with the following:
site:bytes.com CDO email

Now, your challenge includes several key areas.
1. Launch a report and limit it dynamically to a given supplier
2. Create a .pdf file from that report
3. Send an email and attach the .pdf file

Let's say for the moment you are willing to tolerate the security pop-ups. That way you can use the code you already have for sending emails. Below, I'll put a couple relevant threads at Bytes where you can see discussions about forming emails with attachments. This stuff is often version sensitive, so just be aware of that.

The way I do my emailing of reports is to have a loop that processes suppliers and creates a .pdf file and then calls a common function for sending emails. I pass to the function the address, subject, file name(s) to attach and so on. In your case, to use the code you have you might do the reverse, call a function to create the report and return the name of the .pdf file created.

How you create the .pdf will depend in part on what version of MS Office you are using. Later versions make that simpler than in the past. Using version 2003, I rely on the free Bullzip .pdf printer driver to create files for me. But that requires me to automatically set the default printer, which could be another area of study for you. A lot depends on your version.

You've got a lot of challenges ahead. I don't want to overwhelm you with too much information in one reply. Probably you should start by editing your code to automatically attach a given file. That'll be simple. Then, tackle making your report print to a .pdf file. At that point, you'll know better which parts you need more help with. Post back with your results, questions and specific version information.

Jim

http://bytes.com/topic/access/answer...k-address-book
http://bytes.com/topic/access/answer...-automatically
Apr 5 '14 #2

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

Similar topics

0
by: John Silver | last post by:
I have a perl script running on machine A, a web server. A visitor completes certain pieces of data and these are compiled into two emails, one addressed to the visitor and copied to the site...
1
by: Gerry Abbott | last post by:
Hi all, The following code works to output a report myReport, to a file myFile, in ..snp format. --------- DoCmd.OutputTo acOutputReport, "MyReport", "Snapshot Format", MyFile ---------
1
by: Ronnie | last post by:
Newbie question - I am currently able to email a report from Access. However, the report will contain all of the records in the database and not the single record I clicked on to send via...
2
by: Filips Benoit | last post by:
Dear All, SendObject has no where-argument! How can i email a report having user-defined filter, without opening the report? On a unbound form the user can set the criteria for a report....
2
by: Bill | last post by:
I have the user fill in a form and then click a control to send a notice to the lab that the form has been filled in along with the file reference number. I'd like to attach a copy of the form to...
3
by: crjunk | last post by:
Currently I have a Crystal Report that automatically loads as a PDF in the browser whenever the user views the report. This is working great. What I would like to do is add code that automatically...
3
by: ronn2007 | last post by:
Hi, I know sys.tables and sys.columns gives me a list of tables and columns in a SQL 2005 database. How can I list Columns in a specific Table please? Thanks in advance, Ronny
0
by: Pat Bolen | last post by:
Hi, I have a form with a combo box. That cbo box has a simple qry which pulls in two fields, email and name. I want to have two check boxes below the cbo box for view report and email report ...
5
by: tomwor2 | last post by:
I have a single select listbox in a form where when a record is double clicked a report is opened with a filter. The open report action is performed with a macro applying a filter: !=!! I´d...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.