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

passing parameters from vb...just doesn't work

Status
Not open for further replies.

yoink

Programmer
Dec 2, 2001
15
AU
Hi guys,

I've spent most of the day designing an app (vb6, crystal 7) that will export a crystal report into html format and do a bunch of other stuff. That seems to work okay (although when you export a report from crystal 7 into html it makes a complete mess of it...pretty average output actually). Anyhoo, I now want to pass a parameter through to the report so that the user isn't prompted for anything.

To test my code I've been using the "customers.rpt" report that comes with crystal 7. This report only has one parameter which is named "employee name". I've been trying the following:

myReport.ParameterFields(0) = "employee name;John Doe;True"
myReport.ParameterFields(1) = "employee name;John Doe;True"

Q1: Does parameterfields start at 0 or 1? I put them both in but it makes no difference.
Q2: Does this syntax look right? Because it doesn't work. The report keeps opening up and keeps asking me to choose from a list of available parameters (it doesn't even set John Doe to be the default value in the list).
Q3: Do I need brackets if a parameter name is more than one word? How about the value that I'm passing? Does John Doe need to be in brackets or quotes or something?

Any help would be appreciated, this vb/crystal stuff is driving me nuts.

Cheers,

Andrew
 
If you're using the OCX, it's .ParameterFields(0) and the code you have there for (0) is correct.
 
CR7 and the OCX do not support mutli value parameters.

Either upgrade and replace all your OCX code with RDC code,

Or if you are just using the parameter for record selection, stay with CR7 and the OCX and pass that directly to the record selection formula.

Having used the OCX for many years, I'm now a great fan of the RDC and CR8, so recomend that if you want a long term solution. Editor and Publisher of Crystal Clear
 
Thanks guys. I changed things around so that I'm using a CRAXDRT.Application now, and used the following:

Dim crReport As CRAXDRT.Report
Set crReport = crApplication.OpenReport(strReportName)
crReport.ParameterFields(1).AddCurrentValue ("John Doe")

This works fine. Took me ages to work out what I was doing, the help files provided with Crystal weren't very helpful at all. Thank god for tek-tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top