Splitting Query Results into Separate Excel Files to be E-Mailed

smiley1978

Board Regular
Joined
Sep 13, 2005
Messages
133
How would I split the results of a query, by an ID field, into separate tables or dynasets, that can be attached to e-mails as Excel files? My end goal is to run a macro, the macro separates out the data into their respective Excel Sheets and then attaches them to e-mails.

I have a table that has the e-mail address and an ID number that ties back to the table that stores my data.

I have attached files before, but I have not split them out across multiple emails with separate files for each e-mail.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Did you consider the Docmd.SendObject method? You can send the results of a query, based on a criteria field, as one of several formats, including workbooks. If you have several to do as a batch, you'll need to use a recordset of ID's with email addresses and loop through each record, using the ID as sql criteria and the email address of that recordset as the recipient. You can then send the specific records for a given ID to the applicable recipient(s).

I use vba almost exclusively and don't use macros, so I can't tell you what the equivalent steps would be. Hope that helps a bit.
 
Upvote 0

Forum statistics

Threads
1,221,777
Messages
6,161,871
Members
451,727
Latest member
tyedye4

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top