Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    tweak module (2000)

    I was wondering if it is possible to clean or shrink this module anymore than what it already is? Thanks beforehand!

    Function OutputToReport()
    DoCmd.OutputTo acOutputReport, "PO Tracker", acFormatXLS, "d:ReportsPO_Tracker" & Format(Date, "yyyymmdd") & ".xls"
    DoCmd.OutputTo acOutputReport, "BCER-PO Summary", acFormatXLS, "d:ReportsBCER-PO_Summary" & Format(Date, "yyyymmdd") & ".xls"
    DoCmd.OutputTo acOutputReport, "Budget Summary Report", acFormatXLS, "d:ReportsBudget_Summary_Report" & Format(Date, "yyyymmdd") & ".xls"
    End Function

    I'm using a macro to RunCode above.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: tweak module (2000)

    Well, first of all, this is not a module, it's a function. A module is a container that holds code routines, including functions and subs.

    Second, since all this function contains is 3 OutputTo commands, you aren't going to shrink it any. If you wanted to make it possible to add more reports to the function without adding more lines of code, you could tweak the code a bit by using a For Next loop to call a single OutputTo command and pass it different sets of string variables to pass the name of the report and the root name of the destination file. That would allow you to use more loops and add additional values to the arguments instead of adding more OutputTo lines. That would look something like this:

    Function OutputToReport()
    Dim strReport as String
    Dim strDest As String
    Dim intLoop As Integer

    For intLoop = 1 to 3
    strReport = Choose("PO Tracker", "BCER-PO Summary", "Budget Summary Report")
    strDest = Choose("PO_Tracker","BCER-PO_Summary", "Budget_Summary_Report")
    DoCmd.OutputTo acOutputReport, strReport, "d:Reports" & strReport & Format(Date, "yyyymmdd" & ".xls"
    Next intLoop
    End Function
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •