Below is a piece of code I wrote to execute a crystal report and export a character separated text file. I get no errors, but I also get no results. Any suggestions?
Private Sub cmdExport_Click()
Dim Result As Integer
Dim MainJob As Integer
Dim UseSameNumberFormat As Integer
Dim UseSameDateFormat As Integer
Dim StringDelimiter As String
Dim FieldDelimiter As String
Dim TheFileName As String
Dim crApp As New CRAXDRT.Application
Dim crRpt As CRAXDRT.Report
Dim StartRange As String
Dim EndRange As String
Dim TheBank As String
Dim Record_Selection As String
UseSameNumberFormat = 1
UseSameDateFormat = 1
StringDelimiter = ""
FieldDelimiter = ","
StartRange = txtStart.Text
EndRange = txtEnd.Text
TheBank = cboBank.Text
TheFileName = cboApp.Text & txtStart.Text & "-" & txtEnd.Text
' Open print engine
Result = PEOpenEngine()
' Open the selected report
MainJob = PEOpenPrintJob("ReportNamePath" & vbNullChar)
' Set the record selection criteria
Set crRpt = crApp.OpenReport("ReportNamePath"
Record_Selection = "{Chk_No} >= " & StartRange & " and {Chk_No} <= " & EndRange & " and {Bank_Id}= '" & TheBank & "'"
Record_Selection = Replace(Record_Selection, "'", """"
crRpt.RecordSelectionFormula = Record_Selection
' Set export options based on selected export destination
Result = crPEExportToDisk(MainJob, "ExportPath" & TheFileName & ".txt" & vbNullChar, "u2fsepv.dll" & vbNullChar, crUXFCharSeparatedType, UseSameNumberFormat, UseSameDateFormat, StringDelimiter & vbNullChar, FieldDelimiter & vbNullChar)
' Start the print job
Result = PEStartPrintJob(MainJob, 1)
' Close the print job
PEClosePrintJob (MainJob)
' Close the engine
PECloseEngine
End Sub
Private Sub cmdExport_Click()
Dim Result As Integer
Dim MainJob As Integer
Dim UseSameNumberFormat As Integer
Dim UseSameDateFormat As Integer
Dim StringDelimiter As String
Dim FieldDelimiter As String
Dim TheFileName As String
Dim crApp As New CRAXDRT.Application
Dim crRpt As CRAXDRT.Report
Dim StartRange As String
Dim EndRange As String
Dim TheBank As String
Dim Record_Selection As String
UseSameNumberFormat = 1
UseSameDateFormat = 1
StringDelimiter = ""
FieldDelimiter = ","
StartRange = txtStart.Text
EndRange = txtEnd.Text
TheBank = cboBank.Text
TheFileName = cboApp.Text & txtStart.Text & "-" & txtEnd.Text
' Open print engine
Result = PEOpenEngine()
' Open the selected report
MainJob = PEOpenPrintJob("ReportNamePath" & vbNullChar)
' Set the record selection criteria
Set crRpt = crApp.OpenReport("ReportNamePath"
Record_Selection = "{Chk_No} >= " & StartRange & " and {Chk_No} <= " & EndRange & " and {Bank_Id}= '" & TheBank & "'"
Record_Selection = Replace(Record_Selection, "'", """"
crRpt.RecordSelectionFormula = Record_Selection
' Set export options based on selected export destination
Result = crPEExportToDisk(MainJob, "ExportPath" & TheFileName & ".txt" & vbNullChar, "u2fsepv.dll" & vbNullChar, crUXFCharSeparatedType, UseSameNumberFormat, UseSameDateFormat, StringDelimiter & vbNullChar, FieldDelimiter & vbNullChar)
' Start the print job
Result = PEStartPrintJob(MainJob, 1)
' Close the print job
PEClosePrintJob (MainJob)
' Close the engine
PECloseEngine
End Sub