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!

problem with AddCurrentValue method of ParameterFieldDefinition object

Status
Not open for further replies.

bricebu

Programmer
Feb 20, 2004
4
US
Hi everyone,

I've got an application written in VB (.NET) to front-end Crystal Reports. A small and simple chunk of code that used to work, no longer works. I'm wondering what variety of circumstances might exist to cause the code to fail, so I can more easily investigate the specific cause in my application.

Any and all advice will be appreciated. :)

It's a call to the AddCurrentValue method of the ParameterFieldDefinition object:

Rpt.ParameterFields.GetItemByName(Name).AddCurrentValue(value)

where
Rpt is a Crystal Report object
Name(string)="ListID"
Value(variant/object)=30(integer)

The corresponding parameter in the Crystal rpt, "ListID", is a Number.

Before we go any further, I want to make it clear the parameter field IS, WITHOUT QUESTION, USED IN THE REPORT. It is used in Record Selection Formula, and is displayed in the Report Header section.

When I step over the call in debug, I see the following interesting changes to certain properties of the ParameterFieldDefinition object:

1. NeedsCurrentValue changes from True to False
2. IsCurrentValueSet changes from False to True
3. NumberOfCurrentValues changes from 0 to 1.

...but...

4. Value changes from Nothing to... Nothing. Ack!

So, it seems to be executing as expected, but for one thing: the value isn't getting set! And the proof is in the final result: it shows up null/empty in the report, thereby breaking the record selection.

This failure to set parameter values is global - it fails for every parameter in every reports.

What changed in the application, you ask? That's a good question that deserves an answer. Some new code exists to change the data connection and data source (and data source type!) from ADO.NET(XML) to OLEDB (SQL Server) and set the new location of each table. My problem is, I can't see how the new code (which works fine, and was not written by me) broke the parameter field value-setting mechanism.

Weird.

Thanks, all.

~ Brice

FYI Here are the full contents of the debug Command window:

Before AddCurrentValue() executes:

?name
"ListID"
?value
30 {Integer}
[Integer]: 30 {Integer}
?Rpt.ParameterFields.GetItemByName("ListID").IsCurrentValueSet
False {Boolean }
[Boolean]: False {Boolean}
?Rpt.ParameterFields.GetItemByName("ListID").NeedsCurrentValue
True {Boolean}
[Boolean]: True {Boolean}
?Rpt.ParameterFields.GetItemByName("ListID").NumberOfCurrentValues
0 {Short}
[Short]: 0 {Short}
?Rpt.ParameterFields.GetItemByName("ListID").Value
Nothing

After AddCurrentValue() executes:

?name
"ListID"
?value
30 {Integer}
[Integer]: 30 {Integer}
?Rpt.ParameterFields.GetItemByName("ListID").IsCurrentValueSet
True {Boolean}
[Boolean]: True {Boolean}
?Rpt.ParameterFields.GetItemByName("ListID").NeedsCurrentValue
False {Boolean}
[Boolean]: False {Boolean}
?Rpt.ParameterFields.GetItemByName("ListID").NumberOfCurrentValues
1 {Short}
[Short]: 1 {Short}
?Rpt.ParameterFields.GetItemByName("ListID").Value
Nothing


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top