Private Function RptSpooler(reportname As String, p_cod_bank As String, p_cod_branch As String, p_dat_proc As String, p_nam_bank As String, _
p_nam_branch As String, p_user_id As String, p_session_id As String, strDestPath As String) As Boolean
Dim CrApp As CRAXDRT.Application
Dim CrRep As CRAXDRT.Report
Dim myDatabase As CRAXDRT.Database
Dim myDbTables As CRAXDRT.DatabaseTables
Dim myDbTable As CRAXDRT.DatabaseTable
Dim mySections As CRAXDRT.Sections
Dim mySection As CRAXDRT.Section
Dim mySubreport As CRAXDRT.Report
Dim mySubreportObject As CRAXDRT.SubreportObject
Dim myParameterfields As CRAXDRT.ParameterFieldDefinitions
Dim myparamfield As CRAXDRT.ParameterFieldDefinition
Dim crEFTTXT As CRAXDRT.CRExportFormatType
Dim i As Integer
Dim j As Integer
Dim x As Integer
''''''''' On Error GoTo cError
Set CrApp = New CRAXDRT.Application
Set CrRep = CrApp.OpenReport(reportname) ' ("C:\flexcube\host\rptdefn\GL008.rpt")
Set myDatabase = CrRep.Database
Set myDbTables = myDatabase.Tables
'Set myDbTable = myDatabase.Table
CrRep.DiscardSavedData
' CrRep.ParameterFields.GetItemByName("p_cod_bank").AddCurrentValue "44"
' CrRep.ParameterFields.GetItemByName("p_cod_branch").AddCurrentValue p_cod_branch
' CrRep.ParameterFields.GetItemByName("p_dat_proc").AddCurrentValue "01/05/2008"
' CrRep.ParameterFields.GetItemByName("p_nam_bank").AddCurrentValue p_nam_bank
' CrRep.ParameterFields.GetItemByName("p_nam_branch").AddCurrentValue p_nam_branch
' CrRep.ParameterFields.GetItemByName("p_user_id").AddCurrentValue p_user_id
' CrRep.ParameterFields.GetItemByName("p_session_id").AddCurrentValue p_session_id
'CRViewer91.ReportSource =
i = 1
For i = 1 To myDbTables.Count
myDbTables(i).SetLogOnInfo DSN, DSN, uname, pwd
Next i
Set mySections = CrRep.Sections
For Each mySection In mySections
For x = 1 To mySection.ReportObjects.Count
If mySection.ReportObjects(x).Kind = crSubreportObject Then
Set mySubreportObject = mySection.ReportObjects(x)
Set mySubreport = mySubreportObject.OpenSubreport
Set myDatabase = mySubreport.Database
Set myDbTables = myDatabase.Tables
j = 1
For j = 1 To myDbTables.Count
myDbTables(j).SetLogOnInfo DSN, DSN, uname, pwd
Next j
End If
Next x
Next mySection
Set myParameterfields = CrRep.ParameterFields
For Each myparamfield In myParameterfields
With myparamfield
Select Case .ParameterFieldName
Case "p_cod_bank"
.SetCurrentValue p_cod_bank
Case "p_cod_branch"
.SetCurrentValue p_cod_branch
Case "p_dat_proc"
.SetCurrentValue p_dat_proc
Case "p_nam_bank"
.SetCurrentValue p_nam_bank
Case "p_nam_branch"
.SetCurrentValue p_nam_branch
Case "p_user_id"
.SetCurrentValue p_user_id
Case "p_session_id"
.SetCurrentValue p_session_id
End Select
End With
Next
CrRep.EnableParameterPrompting = False
CrRep.ExportOptions.FormatType = crEFTText 'crEFTPortableDocFormat
CrRep.ExportOptions.DestinationType = crEDTDiskFile
CrRep.ExportOptions.DiskFileName = strDestPath
CrRep.Export (False)
' mySection = Nothing
'mySubreport = Nothing
'mySubreportObject = Nothing
Set CrApp = Nothing
Set CrRep = Nothing
' myDbTables = Nothing
'mySections = Nothing
'myParameterfields = Nothing
'myparamfield A = Nothing
'myDbTable = Nothing
'myDatabase = Nothing
RptSpooler = True
'cError:
' If Err.Number <> 0 Then
' MsgBox Err.Description, vbCritical
' Exit Function
' Else
' Me.Caption = Me.Caption + " ..Getting Report data"
' End If
End Function