Report Filter criteria with DoCmd.OutputTo

  • Thread starter Thread starter Ken Olson
  • Start date Start date
K

Ken Olson

I have a list of about 1,000 classmates that I want to publish as a web
page. This code does just that perfectly.

DoCmd.OutputTo acReport, "rptCreateClassmateList", "MS-DOSText(*.txt)",
"C:\ClassmateList.htm", False, "", 0

However, I want to create a separate page for each last name that starts
with the same letter. So I would end up with 26 pages total (Example:
ClassmateList_A.htm, ClassmateList_B.htm, etc.). The code above generates
all the names on one page. I could of course create 26 different queries
using (Like "a*") as the criteria changing the letter for each. Or 26
different reports using the same criteria.

Unless there is a better way I thought that I could simply create 26 lines
of code, each with a different Filter and file name, and execute this code
from a command button on a form. However, I can't figure out how to feed
the OutputTo the Filter.

Thank you,

Ken
(e-mail address removed)
 
Ken

What you could do is write a macro depending updon the first letter like "A*", "B*" etc..
1. Write a Delete Query that Runs 26 Times and every time it runs - it deletes all the records from a temproary table
2. Next Write an append query that would Append Records into the Temproary Table for a Particular Alphabet "A*", "B*" etc.
3. Then you could export the results of step 2 to 26 different files, depending upon the first lette

This is essentially doing the same thing as you said, but you'll have to write 2-3 queries for this job

Rohi
 
Thank you for your reply. While I hadn't thought of your suggested method,
it still leaves me to deal with 26 macros and prompting the user for each of
the 26 file names.

Do you or does any one else have a more streamlined approach? I see web
pages like this everywhere, so I have to believe that someone has already
invented this wheel.

Once again, Rohit I really appreciate the time you took to give me this
initial suggestion.

Ken


Rohit said:
Ken;

What you could do is write a macro depending updon the first letter like "A*", "B*" etc...
1. Write a Delete Query that Runs 26 Times and every time it runs - it
deletes all the records from a temproary table.
2. Next Write an append query that would Append Records into the Temproary
Table for a Particular Alphabet "A*", "B*" etc.
3. Then you could export the results of step 2 to 26 different files,
depending upon the first letter
This is essentially doing the same thing as you said, but you'll have to
write 2-3 queries for this job.
 
Back
Top