Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Custom Code in Reports

Author  Topic 

CoachBarker
Posting Yak Master

170 Posts

Posted - 2009-03-19 : 10:19:27
OK so I went into VS and created a little function in vb.net that takes 2 values and divides the first by the second, and yes I tested it:

Public Shared Function calcloadPounds(ByVal loadPounds As Double, ByVal divisions As Double) As Object
If ISNOTHING(divisions) Or divisions = 0 Then
calcloadPounds = "n/a"
ElseIf loadPounds = 0 Then
calcloadPounds = 0
Else
calcloadPounds = loadPounds / divisions
End If
End Function

So I added the code in the report properties custom code box. and in textbox 16 I added this expression:

= code.calcloadPounds(Fields!textbox18.Value,"PickupDate", Fields!textbox44.Value,"TicketNumber")

and of course it generates these errors:
quote:

[rsFieldReference] The Field expression for the data set ‘NonFormEntry’ refers to the field ‘textbox44’. Report item expressions can only refer to fields within the current data set scope or, if inside an aggregate, the specified data set scope.
[rsFieldReference] The Value expression for the textbox ‘textbox16’ refers to the field ‘textbox18’. Report item expressions can only refer to fields within the current data set scope or, if inside an aggregate, the specified data set scope.
[rsFieldReference] The Value expression for the textbox ‘textbox16’ refers to the field ‘textbox44’. Report item expressions can only refer to fields within the current data set scope or, if inside an aggregate, the specified data set scope.
Build complete -- 3 errors, 0 warnings


so what is the sense in using custom code if you still can not reference an object on a different level. Or have I misunderstood how to use it?
But then I tried this, this is the expression in textbox16, which is right next to textbox18 in the same group:
quote:

The Value expression for the textbox ‘textbox16’ refers to the field ‘textbox18’. Report item expressions can only refer to fields within the current data set scope or, if inside an aggregate, the specified data set scope.


All I want to be able to do is a simple 1st grade division problem and there doesn't seem to be a way to get it. Yellow equals Green divided by Red

Thanks for the help
CoachBarker

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-19 : 10:46:46
why are you using two different datasets fields inside this expression? you cant access individual values of different datasets like this. if you specify scope, you need to specify sometype of aggregation like first(),last(),max(),..
Go to Top of Page

CoachBarker
Posting Yak Master

170 Posts

Posted - 2009-03-19 : 11:22:32
quote:
why are you using two different datasets fields inside this expression? you cant access individual values of different datasets like this. if you specify scope, you need to specify sometype of aggregation like first(),last(),max(),..


Honestly, I have no idea. It seems there is no logical approach to doing anything in SSRS, I can't wait to finish this last report and be done with it for awhile and get back into programming something.

Thanks for the help
CoachBarker
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-19 : 14:20:41
you're not going on logical approach. what meaning does it make to just access two fields from different dataset and forming an expression out of them? please note that there's no concept of order in retrieval from dataset so unless you use some aggregate it doesnt make any sense.
Go to Top of Page

CoachBarker
Posting Yak Master

170 Posts

Posted - 2009-03-19 : 14:45:58
I really am trying to see this, they are not 2 different datasets but they are from 2 different groupings. From what I was reading about custom code, I assumed it was like any other shared function in OOP. Guess I read that wrong.

Thanks for the help
CoachBarker
Go to Top of Page
   

- Advertisement -