Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting/Saving Crystal Report

Status
Not open for further replies.

Visual6Basic

Programmer
Nov 29, 2000
1
ZA
I am using Seagate Crystal Report 8 and Visual Basic 6, I have created my reports outside the VB environment, I am using a Crystal Report Control to view the report. The display is 100%, my problem is saving the report. I have tried all the formats possible, but non seem to work. The best of the lot seems to be RICH TEXT FORMAT. Within my reports I have 9 subreports, most of them have overlapping graphs, the size of the template is 20MB, the size of the file when saved should not exceed 1MB. Any Help would be appreciated!
I came, I saw, I conquered...
 
Have you saved the reports as .rpt files? Does that work?

In what ways do the other formats "not work". I've encountered a lot of problems with supression logic in exports, including Word, which is very annoying.

Usually, the most reliable "save as" format is an .rpt, but that may not work for your users.

Is file size part of the problem? There may be some ways to trim the reports that would reduce the file size.

Kathryn
 
Could someone please help.

I too am using vb to create reports in a batch process. I can create the reports and export them in rtf format. but the formatting gets thrown off pretty much. what I'd really like to do is export it or save it as a crystal report. but when i try this in batch mode i only get my template not the data that was loaded into it. this doesnot happen when i export the file as rtf. below is a sample of my code that does the reporting.

' Function - GenerateReport
' This Function Opens Crystal, Populates the Report Template with data then saves the report
Private Function GenerateReport(lstrAcctName As String, lstrClientName As String, lstrSavePath As String, lstrCounselorName As String, lstrFeeStmtIndicator As String) As Boolean

Const PROC = "GenerateReport"
Dim lstrCrystalReport As String
Dim lRegInfo As AMTS_AQR_DSL.cRuntimeContext
Dim lngErrNum As Long
Dim strErrSrc As String
Dim strErrDsc As String
Dim lstrReportName As String
Dim i As Integer
Dim X As Integer

On Error GoTo ErrorMsg

Set mCrystalApplication = CreateObject("Crystal.CRPE.Application")

Set lRegInfo = New AMTS_AQR_DSL.cRuntimeContext
lstrCrystalReport = lRegInfo.ReportTemplateSource

Job = PEOpenPrintJob(lstrCrystalReport)

'open the report and populate with data
Set mrptCrystalReport = mCrystalApplication.OpenReport(lstrCrystalReport, crOpenReportByTempCopy)
If mrptCrystalReport.HasSavedData = True Then
mrptCrystalReport.DiscardSavedData
End If
Set mCrystalDB = mrptCrystalReport.Database
Set mCrystalTables = mCrystalDB.Tables
Set mCrystalTable = mCrystalTables.Item(1)
mCrystalTable.SetPrivateData 3, g_rstGetLabelData

'new stuff
Set mrptSections = mrptCrystalReport.Sections
For i = 1 To mrptSections.Count
Set mrptSection = mrptSections.Item(i)
Set mrptReportObjects = mrptSection.ReportObjects
For X = 1 To mrptReportObjects.Count
If mrptReportObjects.Item(X).Kind = crSubreportObject Then

Set mrptSubReport = mrptCrystalReport.OpenSubreport(mrptReportObjects.Item(X).Name)
Set mCrystalDB = mrptSubReport.Database
Set mCrystalTables = mCrystalDB.Tables
Set mCrystalTable = mCrystalTables.Item(1)
Select Case mrptReportObjects.Item(X).Name
Case "PPR.rpt"
mCrystalTable.SetPrivateData 3, g_rstGetPPRData
Case "OneYearIPH.rpt"
mCrystalTable.SetPrivateData 3, g_rstGetIPHData
Case "FMI.rpt"
mCrystalTable.SetPrivateData 3, g_rstGetFMIData
Case "PPA.rpt"
mCrystalTable.SetPrivateData 3, g_rstGetPPAData
Case "PPAAccount.rpt"
mCrystalTable.SetPrivateData 3, g_rstGetPPAAccountData
Case "Standard"
If lstrFeeStmtIndicator = "F" Then
mCrystalTable.SetPrivateData 3, g_rstGetFEEData
End If
End Select

End If
Next
Next

lstrReportName = lstrSavePath & lstrAcctName & "-" & lstrClientName & "-" & lstrCounselorName & ".rpt"
' Job = PEOpenPrintJob(lstrCrystalReport)
ExportDll = "u2fcr.dll"
ExportFormat = crUXFCrystalReportType
' result = crPEExportToDisk(job, lstrReportName & Chr(0), ExportDll & Chr(0), ExportFormat, chkNum.Value, chkDate.Value, txtStrDel.Text & Chr(0), txtFieldDel.Text & Chr(0))
result = crPEExportToDisk(Job, lstrReportName & Chr(0), ExportDll & Chr(0), ExportFormat, 0, 0, "" & Chr(0), "" & Chr(0))
If PEStartPrintJob(Job, True) = 0 Then
'ErrorTrap job
End If


'here is where we set the export options
Set mCrystalOptions = mrptCrystalReport.ExportOptions
mCrystalOptions.DestinationType = crEDTDiskFile
mCrystalOptions.formatType = crEFTCrystalReport
mCrystalOptions.DiskFileName = lstrSavePath & lstrAcctName & "-" & lstrClientName & "-" & lstrCounselorName & ".rtf"
mrptCrystalReport.Preview
mrptCrystalReport.Export (False)
'mrptCrystalReport.Save ("C:\test.rpt")



' 'here is where we set the export options
' Set mCrystalOptions = mrptCrystalReport.ExportOptions
' mCrystalOptions.DestinationType = crEDTDiskFile
' mCrystalOptions.FormatType = crEFTRichText
' mCrystalOptions.DiskFileName = lstrSavePath & lstrAcctName & "-" & lstrClientName & "-" & lstrCounselorName & ".rtf"
' mrptCrystalReport.Preview
' mrptCrystalReport.Export (False)

Exit Function

ErrorMsg:
If Err Then
lngErrNum = Err.Number
strErrSrc = Err.Source
strErrDsc = Err.Description
m_objLog.LogEvent vbLogEventTypeError, COMPONENT, MODULE, PROC, _
strErrSrc & " error " & lngErrNum & ": " & strErrDsc
End If
' On Error GoTo 0
' m_strSummary = "Report Processing failed: " & PROC
' m_objLog.LogEvent vbLogEventTypeError, COMPONENT, MODULE, PROC, m_strSummary
Exit Function

End Function



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top