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

Passing Parm from VB to Crystal Report 7.0

Status
Not open for further replies.

odessa79

Programmer
Sep 16, 2003
31
US
Hi,

I got this problem I can't figure out how to pass a parm from VB to Crystal Report 7.0. Am adding a crystal report to my VB project using Data Environment .DSR file. I have one parameter I can't pass that parm into my crystal report.

Any Ideas ???????????????
Please Help asap!!!!!!!!!!!!!!!!!!!!!1

Thanks
 
A quick search found many threads on the topic. Thread222-558607, for example.

Thanks and Good Luck!

zemp
 
I think so. That thread is pointing to defferent subject. Please let me know if you have any solutions.
 
Well, did you do as zemp did?!!!
("quick search found many threads...")

I did the same using and all word search using:
Crystal Parameters DSR
 
Crystal 8.0 - might work for 7.0

CrxRpt.ParameterFields(x).ClearCurrentValueAndRange
CrxRpt.ParameterFields(x).AddCurrentValue (value)
[flowerface]

"All I ask is the chance to prove that money can't make me happy." - Spike Milligan
 
Yes there was a typo in the thread link, Sorry.

Try thread222-588607.

My search words were 'Crystal report paramater'

Thanks and Good Luck!

zemp
 
Guys I still having a problem with this.
here is my code

Dim CrystalApp As New CRAXDRT.Application
Dim CrystalRpt As New CRAXDRT.Report
Set CrystalApp = CreateObject("CrystalRunTime.Application")
Set CrystalRpt = CrystalApp.OpenReport(gRptPath)

'I get an error type mismatch
CrystalRpt.ParameterFields.Item("EmpName").AddCurrentValue WrkName

'and if i use it this way it does not pick up the value of the parameter. I get a Crviewer with all the employees in the file

CrystalRpt.ParameterFields.Item(1).AddCurrentValue WrkName




CRViewer1.ReportSource = CrystalRpt
CRViewer1.ViewReport

Please help
 
Here is what I use,

Dim crxReport As New CRAXDRT.Report
Dim crxParam As CRAXDRT.ParameterFieldDefinition

Set crxParam = crxReport.ParameterFields.Item(1)
crxParam.ClearCurrentValueAndRange
crxParam.AddCurrentValue "My parameter"

I am using the parameter fields definition object to assign the parameter values to and not the report object itself.

Hope this helps.


Thanks and Good Luck!

zemp
 
Did not work any more suggestions?

Here is my code
Dim CrystalApp As New CRAXDRT.Application
Dim CrystalRpt As New CRAXDRT.Report
Dim CrystalParam As CRAXDRT.ParameterFieldDefinition

Set CrystalApp = CreateObject("CrystalRunTime.Application")
Set CrystalRpt = CrystalApp.OpenReport(gRptPath)

Set CrystalParam = CrystalRpt.ParameterFields.Item("EmpName")
CrystalParam.ClearCurrentValueAndRange
CrystalParam.AddCurrentValue ("WrkName")

I get the type mismatch error.
 
Did you try puting in a '1' instead of 'EmpName' for your parameter field index.

Set CrystalParam = CrystalRpt.ParameterFields.Item(1)

The intellisense says that the index is a long. So if you place a string where it is expecting a long then you would get the type mismatch error.

Thanks and Good Luck!

zemp
 
I did try that it does not come up with an error but it does not pass the parm over
 
I think CCLINT is suggesting that the Item collection may be zero based. That is the first element or parameter could be,

Set CrystalParam = CrystalRpt.ParameterFields.Item(0)

I don't think so. If I pass only one parameter I start with 1.

Could the problem be else where? In the .rpt file? Is the parameter correct in that it filters the data you want?

Thanks and Good Luck!

zemp
 
Try changing the line that reads:
CrystalRpt.ParameterFields.Item("EmpName").AddCurrentValue WrkName

To:
CrystalRpt.ParameterFields(1).AddCurrentValue WrkName

You will need to confirm that this is the first parameter in the report, or change the index to the correct parameter number, 1 based. You should also confirm that the parameter in the report is a string parameter, if you are trying to pass a string to a paramter set for a different data type, you will get the error message you indicated.

Jim Varco
jimv@varcconsulting.com
 
Odessa, Please let me know if you solve this as i have almost the exact same problem.


Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top