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!

Crystal Parameters in Visual Basic

Status
Not open for further replies.

Jacob438

Programmer
Jul 27, 2001
69
0
0
US
I am working on a VB app to generate crystal reports. Anyways, I need to pass some parameters into a crystal report. I have the report all ready and it works, and it is saved as a .rpt file. It works fine in my VB form using the Crystal Report Control Component, and I have my source code below. The only problem is, I want to do this with very minimal user input (for automation sake). How do I suppress the pop up box asking for input parameters, and how do I pass parameters into the report?

Source code (it's very simple right now):
Private Sub cmdRun_Click()
CrystalReport1.PrintReport
End Sub

Private Sub Form_Load()
CrystalReport1.Connect = "PWD=report"
End Sub

Thank you,

jacob schroeder
 
here's the important stuff...

I am using the .ocx (activeX control)
Crystal Reports 7
VB 6

Hope that helps
 
try this--------->In ur VB application, include the reference Crystal Report Engine 7 Object Library.(from MenuItem Project --> Reference)

Option Explicit
Dim creParaFldDefs As CRPEAuto.ParameterFieldDefinitions
Dim crePara As CRPEAuto.ParameterFieldDefinition
Dim rptDB As CRPEAuto.Database
Dim rptTbls As CRPEAuto.DatabaseTables
Dim rptTbl As CRPEAuto.DatabaseTable
Dim creApp As CRPEAuto.Application
Dim CreRpt As CRPEAuto.Report


Private Sub CmdGenerate_Click()
Set creApp = New CRPEAuto.Application
Set CreRpt = creApp.OpenReport(App.Path & "your report name.rpt")
Set rptDB = CreRpt.Database
Set rptTbls = rptDB.Tables
Set rptTbl = rptTbls.Item(1)
rptTbl.SetLogOnInfo "servername", "databasename", "userid", "password"
Set creParaFldDefs = CreRpt.ParameterFields
Set crePara = creParaFldDefs.Item(1)
crePara.SetCurrentValue "parameter value"
CreRpt.Preview

Set crePara = Nothing
Set creParaFldDefs = Nothing
Set CreRpt = Nothing
Set creApp = Nothing

end sub
 
Allright, I'm kind of conufsed about the different way to implement these. What are the benefits of using the object library, or the dll, or the activeX?

Jacob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top