Crystal Report: SetParameterValue not doing what it says!!!!!

A

Alex Stevens

Hi all,

I'm having trouble setting a boolean parameter in a crystal report which I'm
calling from a VB.net windows Form application.

The parameter is called ShowScrappedOnly and is set to a boolean.

This is the code that I try to set the value with:

rptReport.ReportDocument.SetParameterValue("ShowScrappedOnly",
chkScrappedOnly.Checked)

chkScrappedOnly.Checked is a checkbox on a form and evaluates to True or
False.

When the report is run the parameter dialog box comes up asking for the
parameter I've just set. However, if I spell the parameter name wrongly it
gives an error of "Invalid Field Name"

I include this line to check the value of the parameter:

rptReport.ReportDocument.DataDefinition.ParameterFields("ShowScrappedOnly").
CurrentValues.Count
and it gives me 1.

It's obvious that the report is not getting the value that I set, as the
dialog is popping up, but on the flip-side if I set the parameter with the
wrong name it complains???

Any ideas on this anyone?

Alex Stevens
 
C

Christopher C. Kane

Alex said:
Hi all,

I'm having trouble setting a boolean parameter in a crystal report which I'm
calling from a VB.net windows Form application.

The parameter is called ShowScrappedOnly and is set to a boolean.

This is the code that I try to set the value with:

rptReport.ReportDocument.SetParameterValue("ShowScrappedOnly",
chkScrappedOnly.Checked)

Verify your Type for the input parameter in the report is Boolean.
Otherwise, try using the ToString() Method.
chkScrappedOnly.Checked is a checkbox on a form and evaluates to True or
False.

When the report is run the parameter dialog box comes up asking for the
parameter I've just set. However, if I spell the parameter name wrongly it
gives an error of "Invalid Field Name"

Crystal Reports Parameters are case sensative.
I include this line to check the value of the parameter:

rptReport.ReportDocument.DataDefinition.ParameterFields("ShowScrappedOnly").
CurrentValues.Count
and it gives me 1.

It's obvious that the report is not getting the value that I set, as the
dialog is popping up, but on the flip-side if I set the parameter with the
wrong name it complains???

It should because the Parameters are case sensative, thereby causing an
Exception.
 
A

Alex Stevens

Christopher - many thanks for your reply.
I discovered the problem, was for some obscure reason I was calling the
report's .Refresh method before opening it.
This was causing all the parameters to be removed!!!

Thanks again.

Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top