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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting Crystal Reports

Status
Not open for further replies.

tenbobmillionaire

Programmer
Jun 13, 2000
27
EU
I posted this in the VB general discussion area with no success, maybe someone in here can help...

Does anyone have any demo code on how to export a crystal report using VB? I need to allow a user to enter a field in a text box in a VB form, then pass this parameter to crystal (version 6) , generate the report using this parameter, export to html and email the user with the html file as an attachment. Simple as that.(?)

I've never used crystal with VB before so any help is greatly appreciated.

Mick




 
This is the sort of thing you may need
Sorry the formatings to pot but they have changed this site layout. The report to be run is set into a var and in the section marked ##### the report is sent to crystal fro printing but as a text file, in this app the report is printed out to disk as a text file. I cant see why you could not do this with the html options as well.

Regards Dave

'Set the path to the report
Select Case UCase(arrstrReportOptions(11))
Case "RETAIL"
strReportPath = mstrReportsPath & "PortWorthRetail.rpt"
Case "CORPORATE"
Select Case strCurrentType
Case "M" 'Group Members
strReportPath = mstrReportsPath & "PortWorthCorpTeam.rpt"
Case "G" 'Group
strReportPath = mstrReportsPath & "PortWorthCorp.rpt"
End Select
End Select
MDIMain.CrystalReport.ReportFileName = strReportPath

'Discard saved data
MDIMain.CrystalReport.DiscardSavedData = True

'Set the report parameters
MDIMain.CrystalReport.StoredProcParam(0) = strPeriod 'Report Period
MDIMain.CrystalReport.StoredProcParam(1) = strRegionCode 'Region Code
MDIMain.CrystalReport.StoredProcParam(2) = arrstrReportOptions(8) 'Area Code
MDIMain.CrystalReport.StoredProcParam(3) = arrstrReportOptions(9) 'Branch Code
MDIMain.CrystalReport.StoredProcParam(4) = arrstrReportOptions(10) 'Manager Code

'Set the number of StoredProcParam's opened
mintProceduresOpen = 5

'Set report destination
If UCase(arrstrReportOptions(15)) = "PRINTER" Then
MDIMain.CrystalReport.Destination = crptToPrinter
Else ######
strReportPath = Left$(strReportPath, Len(strReportPath) - 3) & "txt"
MDIMain.CrystalReport.PrintFileName = Left$(strReportPath, Len(strReportPath) - 3) & "txt"
MDIMain.CrystalReport.PrintFileType = crptText
MDIMain.CrystalReport.Destination = crptToFile
End If

Dave
dab@completebs.com
See website for more info but we can develop most things for most people.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top