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!

Help passing parameters to CR from VB

Status
Not open for further replies.

smalley

Programmer
Feb 8, 2001
17
0
0
US
I created a report with one parameter. When I view the report data, I am prompted for the parameter value and the report data is filtered based on what I enter. This works fine. What I would like to do is pass the parameter value from VB to the report without it prompting the user. This is what I tried:
rpt.ParameterFields.Item("CheckNo").Value = 170909
I get a type mismatch error with this line.
rpt.ParameterFields(1).Value = "170909"
I get an "Object Required" error with this line.

Please help!!!
Holly
holly.smalley@umb.com
 
Which integration method are you using. If unsure, see the FAQ on "Information to include with your question". Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Here is the information that I should have included with my initial question:

I am using CR Version 8.0.1
I am using VB Version 6
I am using the CRViewer.dll and launch the report using the following code:

Dim rdApp As CRAXDRT.Application
Dim rpt As CRAXDRT.Report

Set rdApp = CreateObject("crystalruntime.application")

Set rpt = rdApp.OpenReport(App.Path & "\" & rptName)

Call rdApp.LogOnServer ("pdsodbc.dll", "PAC", "PAC", "PACappl", "home")

CRViewer1.ReportSource = rpt
CRViewer1.ViewReport
 
Instead of .Value try either:

.AddDefaultValue("XXX")

or

.AddCurrentValue("XXX")

You can look up the difference in the developer's help file.

Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
I am facing the same problem. But the parameter I need to pass is a date.
Can you help me pls?
Thx in advance.
-Avinash
 
Hey...I got the solution.
It could be passed in the following manner...

rpt.ParameterFields(1).AddDefaultValue (#7/12/2001#)

Thx anyways.
Have a great day.
-Avinash
 
Thanks for the help.
.AddDefaultValue("XXX") didn't work the way I wanted because it still prompted me for a value.

.AddCurrentValue("XXX") works great for what I needed!!

Thanks again.
 
Hey...
If you want to suppress the prompting of the dialog box for values, use the following code...

rpt..EnableParameterPrompting = False

This will not make the dialog box appear.
Hope this will help you.
-Avinash
 
I have a VB form in which i have a combo box for the Months of a year.I want to pass this combo box value to the Crystal Report wherin i want to query the database using this value and generate a report.
can anyone help me out how to do this and how to pass values to crystal reports.
 
Hi smalley !!

I have tried this with Crystal Report 7.0 and VB 6.0 and this is working fine.

RPT.ParameterFields(1) ="ParameterName;ParameterValue;true"

--- If You want to pass the value of variable then ---

RPT.ParameterFields(1) ="ParameterName;" & VariableName &";true"


All The Best ,

Rajesh R.
roboreb@hotmail.com
 
To all,

It may be less finicky to pass a formula definition instead of a parameter. I create formulas with default values in the report, then if the default is not appropriate, I have VB replace the formula with one that returns the value I need to pass.

Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top