Help: QueryDef, ADO, or DAO?

woodchuckwood

Registered User.
Local time
Today, 18:59
Joined
Jan 15, 2004
Messages
10
Here is an idea of what i'm doing:
-------------------------------------------------------
Code:
Private Sub Command3_Click()
    Dim index As Integer
    Dim report(5) As String

    report(0) = "ALL_TableA19"
    report(1) = "ALL_TableA12"
    report(2) = "ALL_TableA15a"
    report(3) = "Asia_TableA15b"
    report(4) = "Europe_TableA6a"

  
    For index = 0 To 4

    DoCmd.OutputTo acOutputReport, report(index), "RichTextFormat(*.rtf)", "C:\test\" & report(index) & ".doc", False, ""
 

    Next index
 
End Sub

---------------------------------------------------------------------------
clarification: "ALL_Table...Asia_Table...&Europe_Table" are titles of reports. Reports with the title "ALL_Table" apply to all regions.

So the application works as follows:
User selects a specific region in a form.
A cmd button generates those reports specific to the chosen region into a folder.

An error occurs when the region selected does not match with the report. ex: If Europe is the selected region, then "ALL_Table" reports print out but the stops when it sees that the Europe region does not apply to the "Asia_Table" report.

Hardcoding all of these reports to the index is way too much work(100+ reports).

Ideas for possible solutions:
ADO
DAO
QueryDef Method

I hope anyone can give some helpful advice and some lines of code to get me out of this mental block.





Reports with the title "ALL_Table" apply to all regions. :confused:
 
Last edited by a moderator:
MS Knowledge Base Article based on

Code:
Public Sub ListReports()

   Dim db As DAO.Database, doc As Document, con As Container
   Set db = CurrentDb()
   Set con = db.Containers("Reports")
   For Each doc In con.Documents
      Debug.Print doc.Name
   Next


End Sub


You can then compare the doc.Name to the parameter to determine which reports print.
 

Users who are viewing this thread

Back
Top Bottom