|
|
Печать большого количества отчётов (с логом в текстовом файле - опционально)
ublic Function StartReport01() As Integer
Dim iCount As Integer, iCountEnd As Integer
Dim sNoFormat As String
Dim sReportName As String
Dim sReportText As String
Dim sReportPath As String
On Error GoTo StartReport_Err
iCountEnd = 2000
sNoFormat = "00000"
sReportName = "rptTest"
sReportPath = "D:\Temp\Temp001.txt"
If Dir(sReportPath, vbNormal) <> "" Then Kill sReportPath
Open sReportPath For Append As #1
For iCount = 1 To iCountEnd
Application.DoCmd.OpenReport sReportName, acNormal
Print #1, Format(iCount, sNoFormat); " - "; sReportName
Next iCount
MsgBox "Done!", vbInformation, "Printing Report " & sReportName
StartReport_End:
On Error Resume Next
Close #1
Exit Function
StartReport_Err:
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"in Function: StartReport in module: 00ModuleForTests", vbCritical, "Error in Application"
Err.Clear
Resume StartReport_End
End Function
Public Function StartReport02()
Dim iCount As Integer, iCountEnd As Integer
Dim sNoFormat As String
Dim sReportName As String
Dim sReportText As String
Dim sReportPath As String
Dim iMet100%, x%, iMetAll%
Dim sFilter$
On Error GoTo StartReport_Err
iCountEnd = 2000
sNoFormat = "00000"
sReportName = "rptTest"
sReportPath = "D:\Temp\Temp001.txt"
If iCountEnd > 100 Then iMet100 = iCountEnd \ 100 Else iMet100 = 1
SysCmd acSysCmdClearStatus
SysCmd acSysCmdInitMeter, "Printing Report " & sReportName & " ...", 100
If Dir(sReportPath, vbNormal) <> "" Then Kill sReportPath
DoCmd.OpenReport sReportName, acViewPreview , , acHidden
Open sReportPath For Append As #1
For iCount = 1 To iCountEnd
sFilter = "RecID = " & iCount
'
Reports(sReportName).Filter = sFilter
Reports(sReportName).FilterOn = True
'Debug.Print "Filter: " & sFilter, vbInformation, "Printing Report " & sReportName
DoCmd.PrintOut , , , acMedium, 1
Print #1, Format(iCount, sNoFormat); " - "; sReportName
x = iCount \ iMet100
If x > iMetAll Then
iMetAll = x
'Debug.Print iMetAll & "%"
SysCmd acSysCmdUpdateMeter, iMetAll
End If
Next iCount
Reports(sReportName).Filter = ""
Reports(sReportName).FilterOn = False
DoCmd.Close acReport, sReportName
MsgBox "Done!", vbInformation, "Printing Report " & sReportName
SysCmd acSysCmdClearStatus
StartReport_End:
On Error Resume Next
Close #1
Exit Function
StartReport_Err:
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"in Function: StartReport in module: 00ModuleForTests", vbCritical, "Error in Application"
Err.Clear
Resume StartReport_End
End Function
|
|