Good Morning,
I have been trying a few different ways to get the job done, but it never works.
mission: i need to run a cr .rpt, offer parameter values, and then export a pdf to a file.
here is what is have already, but this is giving me errors abound.
if someone could steer me in the right direction, that would be great!!
there is urgency to this project! but then again, isn't every project?
i have the luxury of using
vb express, so i cannot simply add a CR into my project.
Public crConn As ADODB.Connection
Public crRS As ADODB.Recordset
Public crApp As CRAXDDRT.Application
Public crRpt As CRAXDDRT.Report
Public crSQL As String
Public crDBTable As CRAXDDRT.DatabaseTable
Test.crViewer.DisplayBorder = False
Test.crViewer.DisplayTabs = False
Test.crViewer.EnableDrillDown = True
Test.crViewer.EnableRefreshButton = True
crConn = New ADODB.Connection
crConn.CursorLocation = ADODB.CursorLocationEnum.adUseClient
crConn.ConnectionString = "DSN="MyDSN";UID="username";Pwd=;"
conn.Open()
~~errors here cannot connect to DSN
rs = New ADODB.Recordset
crSQL = "SELECT STATEMENT W/ PARAMETERS"
rs.Open(crSQL, crConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly)
crApp = New CRAXDDRT.Application
crRpt = crApp.OpenReport("C:\Crystal\report.rpt")
crRpt.DiscardSavedData()
crRpt.Database.SetDataSource(crRS)
Test.crViewer.ReportSource = crRpt
Test.crViewer.ViewReport()
crRpt.ExportOptions.DiskFileName = "C:\Crystal\Output.pdf"
crRpt.ExportOptions.DestinationType = CRExportDestinationType.crEDTDiskFile
crRpt.ExportOptions.FormatType = CRExportFormatType.crEFTPortableDocFormat
crRpt.Export(False)
crRS.Close()
crRS = Nothing
crConn.Close()
crConn = Nothing
crApp = Nothing
crRpt = Nothing