Using MS Access/Auto Email

Advertisement


Question
I have 2 very simple tables - one listing multiple supplier numeric IDs and associated email address in 2 seperate fields, the other many rows of sales data, unique by supplier id and a product number (many suppliers, many products). I am trying to create code that will automatically create an email by supplier, with an attachment (.xls or .csv)of their specific data from the sales table. I cannot work through how to connect the email address in a recordset loop, to creating a specific qry for that supplier and attaching that result to the email - can you help ?

Answer
Have you looked at the SendObject method? That allows you to send the results of a query as an XLS file to an e-mail address.

If you want to send a filtered recordset within a loop, then you will have to use a Querydef to define the query with a filter based on the supplier. As to the e-mail address you simply populate that paramter with the e-mail field from the current record.

If just sending a single e-mail to a selected supplier, you use a stored query that filters for the supplier selected on a form. You set the criteria for the supplierID using the syntax:

=Forms!formname!controlname

Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

©2012 About.com, a part of The New York Times Company. All rights reserved.