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 parameter from VB to Crystal Reports

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.

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
 
Don't know if this will help you but what I did was create a temporary table that I deleted after I populated my report with all the data required. I had a SQL statement that basically filtered the data based on some parameter and gave me the info needed for the report. Then I did a basic show report. All this was done with VB code. If you are interested in this method let me know and I will try and help you.


Joanne
 
Thanks for the help Joanne. Initially, I was going to create a temporary table and drop it when I was finished but our DBAs will not allow us to do that. That is what created this issue. They required me to create my report without the use of temp tables. Sure was a lot easier your way!!
Thanks,
Holly
 
Hi Holly,

Definately easier with Temp tables, how about setting it equal to a declared variable before you set it. Such as :

Dim MyValue as string
MyValue = 170909
rpt.ParameterFields.Item("CheckNo").Value = MyValue

not sure if that will help or not but sometimes its worth a shot :)

Joanne
 
what i did to pass a parameter in CR 8.5 was

Report.ParameterFields(1).AddCurrentValue YourVariable

or

Report.ParameterFields(1).AddCurrentValue "170909"

if you don't want the prompt:

Report.EnableParameterPrompting = False
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top