Hi
First of All, Ken, thanks so much for making these available to everyone,,
you have saved a lot of people many hours of work!!!!
I have looked at Ken's Examples for Exporting to EXCEL Workbook Files--
and
I am a bit confused if this is what I need.
I already have a query built that has a paramater asking the user which
Rep
to filter by,, or if they leave it blank, it displays all Reps.
i want to be able to run the query and export one file for each rep if
they
leave it blank
Can anyone tell me which of Kens examples if any,, is the right solution.
HERE is my sql
SELECT RS.[Rep ID], RBPT.[Week Start Date], RBPT.STATION, M.Market,
RBPT.[Customer ID], RBPT.[Product Name], RBPT.[Flight Start Date],
RBPT.[Flight End Date], RBPT.[DR Rep], RBPT.[Primary Day Part] AS [Prim
DP],
RBPT.[Rotator Day Part], RBPT.[Other Day Part], RBPT.[Opt In], RS.[Format
ID], RBPT.[# Prime Spots], RBPT.[# Rot Spots], RBPT.[# Other Spots],
CON.[E-mail Address], CON.[Mobile Phone] AS Cell, Sum(([Prime Rate]*[#
Prime
Spots]+[Rot Rate]*[# Rot Spots]+[RBPT.Other Rate]*[# Other Spots])) AS
Total,
RBPT.[Prime Rate], RBPT.[Rot Rate], RBPT.[Other Rate], M.[State ID],
RS.[Station Comments], Buy.[Buy Status], RBPT.[Buy Status Comments], [REP
TABLE].[Rep Contact_Main], [REP TABLE].[Rep Contact_Second], RS.[Contact
ID],
RS.[Contact Full Name]
FROM ((([Contacts Merged Table] AS CON RIGHT JOIN ([RADIO BUY AND POST
TABLE] AS RBPT LEFT JOIN [RADIO STATIONS TABLE] AS RS ON RBPT.STATION =
RS.[Station Call Letters]) ON CON.[Contact ID] = RS.[Contact ID]) LEFT
JOIN
[Buy Status Table] AS Buy ON RBPT.[Buy Status] = Buy.[Buy Status]) LEFT
JOIN
[MARKETS TABLE] AS M ON RS.[Market ID] = M.[Market ID]) INNER JOIN [REP
TABLE] ON RBPT.[Station Rep] = [REP TABLE].[Rep ID]
GROUP BY RS.[Rep ID], RBPT.[Week Start Date], RBPT.STATION, M.Market,
RBPT.[Customer ID], RBPT.[Product Name], RBPT.[Flight Start Date],
RBPT.[Flight End Date], RBPT.[DR Rep], RBPT.[Primary Day Part],
RBPT.[Rotator
Day Part], RBPT.[Other Day Part], RBPT.[Opt In], RS.[Format ID], RBPT.[#
Prime Spots], RBPT.[# Rot Spots], RBPT.[# Other Spots], CON.[E-mail
Address],
CON.[Mobile Phone], RBPT.[Prime Rate], RBPT.[Rot Rate], RBPT.[Other Rate],
M.[State ID], RS.[Station Comments], Buy.[Buy Status], RBPT.[Buy Status
Comments], [REP TABLE].[Rep Contact_Main], [REP TABLE].[Rep
Contact_Second],
RS.[Contact ID], RS.[Contact Full Name], RBPT.[Campaign ID], RBPT.Keep,
RS.[Contact ID]
HAVING (((RS.[Rep ID]) Like "*" & [Enter Rep Firm, or leave blank for
ALL ]
& "*") AND ((RBPT.[Week Start Date])=[Forms]![Weekly Buy Table Form]![Week
Start Date]) AND ((RBPT.[Campaign ID])=[Forms]![Weekly Buy Table
Form]![Campaign ID]) AND ((RBPT.Keep)=Yes))
ORDER BY RS.[Rep ID], RBPT.STATION;
Nancy
Ken Snell MVP said:
Create a Query and Export multiple "filtered" versions of a Query (based
on
data in another table) to separate EXCEL files via TransferSpreadsheet
(VBA)
http://www.accessmvp.com/KDSnell/EXCEL_Export.htm#FilterExportSepFiles
--
Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/