Results 1 to 5 of 5

Thread: turbo charge this code??? - Part 1

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2010
    Posts
    7

    turbo charge this code??? - Part 1

    need help. Access 2003 dB with a couple processes that run awful slow. Here's one module that takes about 3-4 hours to run for 130 unique records to create about 400 externally stored files. 2 out of every three files are PDF. the other is Excel.

    Code:
    ' Purpose : Contains procedures used in exporting data to files and sending files in email.
    '---------------------------------------------------------------------------------------
    
    Option Compare Database
    Option Explicit
    
    Private Const SMTP_SERVER As String = "smtpgate.petc.com"
    
    '---------------------------------------------------------------------------------------
    ' Procedure : RunExport
    ' Author : xxxxx
    ' Date : 7/3/2008
    ' Purpose : Exports Scorecard or Statement and PODetail spreadsheets to files.
    ' ReportName is the report to be run
    '---------------------------------------------------------------------------------------
    '
    Public Sub RunExport(ReportName As String)
    On Error GoTo RunExport_Error
    
    Dim rs As DAO.Recordset
    Dim sFilePath As String
    Dim sTempPDFPath As String
    Dim I As Integer
    Dim bContinue As Boolean
    
    Set rs = CurrentDb.OpenRecordset("Select * From tblVendors WHERE Active = True;")
    
    'Get the base path from the paths table
    sFilePath = GetFilePath("Export")
    
    'Get temp path from the paths table
    sTempPDFPath = GetFilePath("TempPDFPath")
    
    If ReportName = "rptFinalInvoice" Then
    sFilePath = sFilePath & Format(Date, "mmddyy") & "_statements\"
    Else
    sFilePath = sFilePath & Format(Date, "mmddyy") & "\"
    End If
    
    If Dir$(sFilePath) = "" Then
    If Not CreateWindowsDirectory(sFilePath) Then GoTo RunExport_Error
    End If
    
    bContinue = True
    
    'loop through vendors, outputting files
    Do While Not rs.EOF And bContinue
    
    'Ouput PO Detail spreadsheet and Scorecard report to pdf
    'if either returns false bail out of the process
    
    bContinue = PODetail2Excel(rs("VENDID"), sFilePath & Format$(rs("VENDID"), "00000") & " Detail" & ".xls") And _
    PrintPdf(ReportName, "[VendID]=" & rs("VENDID"), sTempPDFPath, sFilePath, Format$(rs("VENDID"), "00000") & " " & " Scorecard" & ".pdf") And _
    PrintPdf("rptCharts", "[VendID]=" & rs("VENDID"), sTempPDFPath, sFilePath, Format$(rs("VENDID"), "00000") & " " & " Charts" & ".pdf")
    
    rs.MoveNext
    
    Loop
    
    If bContinue Then
    MsgBox "Export Complete."
    Else
    MsgBox "Export aborted before it was finished, please check the files in the export folder"
    End If
    
    RunExport_Error:
    
    If Err.Number <> 0 Then
    ProcessError Err.Number, Err.Description, "RunExport", "Module: modExports"
    End If
    
    On Error Resume Next
    
    End Sub

    *****go to Part 2 Thread************
    Last edited by kkozar; May 28th, 2010 at 10:31 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width