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

Pass parameters from VB 6.0 to Crystal 8.5 AND export to pdf

Status
Not open for further replies.

dancarr22

Programmer
Oct 15, 2002
8
0
0
CA
I need to pass parameters from VB 6.0 to Crystal 8.5.
Then, export the report as a pdf

If I do not assign values to the parameter this works and exports (to pdf) the previously saved values.
If I just pass the parameters and view the report it works.
BUT when I do both I get a 'Server has not yet been opened' message
I have tried switching CRAXDDRT to CRAXDRT for each declaration.
Also, the SetLogOnInfo is correct and is the same (info) as the report

Dim crxExportOptions As CRAXDDRT.ExportOptions
Dim crxApplication As New CRAXDDRT.Application
Dim crxReport As CRAXDDRT.Report
Set crxReport = crxApplication.OpenReport(App.Path & "\" & "TEST.rpt")
'crxReport.DiscardSavedData
crxReport.Database.Tables(1).SetLogOnInfo "SQL01", "dbname", "dev1", "dev1"
'Set the parameters
crxReport.ParameterFields(1).AddCurrentValue strBegin
crxReport.ParameterFields(2).AddCurrentValue strEnd
Set crxExportOptions = crxReport.ExportOptions
crxReport.ExportOptions.DestinationType = crEDTDiskFile
crxExportOptions.DiskFileName = "c:\" & strRepName & ".pdf"
crxReport.ExportOptions.FormatType = crEFTPortableDocFormat
crxReport.Export False

Thank You
 
If you still need a method for generating a Crystal .pdf from a VB script, this worked for us:

Rptname = "I:\Crystal\" + ParmSyst + "\" + Parm1 + ".RPT"
Set Apps = CreateObject("CrystalRuntime.Application")
Set Report = Apps.OpenReport(Rptname)

Set CrTable = Report.Database.Tables(1)
parm5 = parm5 + ".PDF"
Report.ParameterFields.Item(1).AddCurrentValue parm4
CrTable.SetLogOnInfo "", "", Parm2, Parm3
Dim ExportOptions As CRAXDRT.ExportOptions
With Report.ExportOptions
.DestinationType = crEDTDiskFile
.DiskFileName = parm5
.FormatType = crEFTPortableDocFormat
End With
Report.Export False

Hope that this helps.
Parm 1 is Crystal report name
Parm 2 is Logon Name (AS/400)
Parm 3 is Password (AS/400)
Parm 4 is record selection value
Parm 5 is name of .pdf file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top