views:

26

answers:

1

Can you do this? The list filter I want to use looks like this:

Expression                                      Operator    Value
=Code.GetOccCat(Fields!accountnumber.Value)     =           =1

No dice. Basically, it acts like that function returns null as far as the filter is concerned, but when I take the filter off and put the exact same function call in a text box within the list, it returns what it's supposed to return. Can you just not do this, or what am I missing?

Edit: here's the function, completely simple:

Public Function GetOccCat(ByVal AccountNum As Integer) As Integer
Return OccCat(AccountNum)
End Function

OccCat is a public array of integers that is filled via an earlier function call. Again, the correct values display if I just put this in a text box, so the array is verified to be filling up correctly.

Edit: the array gets populated by way of a list at the top of the report. The list repeats on accountnumber with no filter. Inside the list is a textbox containing this code:

=Code.SetOccupancy(Fields!accountnumber.Value, First(Fields!new_total_hours.Value)/First(Fields!new_capacity.Value))

And here's that function:

Public Function SetOccupancy(ByVal AccountNum As Integer, ByVal Occ As Double) As String
Occupancy(AccountNum) = Occ
Select Occ
    Case Is > .85
        OccCat(AccountNum) = 1
    Case .7 to .849
        OccCat(AccountNum) = 2
    Case .4 to .699
        OccCat(AccountNum) = 3
    Case Is < .4
        OccCat(AccountNum) = 4
End Select
Return ""
End Function

FWIW, I've also tried this filter based on the Occupancy array (being > .85 in this case) and gotten the same result.

A: 

Could you show your function in your code?

I just checked it, and it certainly works to filter off of custom code. Though I didn't use yours exactly because I don't quite understand what you are trying to filter by.

Which field are you wanting to filter by?

I think you are just putting your code for your expression in the wrong place. Basically, put the field you want to filter by in the expression box that drops down. Then place your =code.getocccat(my value) in the value expression.

Try this and let me know, but it certainly works. I think you have the placement a little off.

I've put it in, but it's extremely simple.
extarbags
Just made an edit, please check it and let me know.
I'm not trying to filter based on a field per say, I'm actually trying to filter based on the result of a function call with the field passed as a parameter. In other words, what I actually want is for it to evaluate Code.GetOccCat(accountnumber) and display the rows for which that returns 1.
extarbags
Ah I understand what your wanting now, I just modified my version to be an expression thats evaluating a field and in the code I'm taking the field passed and adding some value onto it. It works just as intended. So I believe the issue is coming from the array or when the array is being populated. Could you post how your populating the array and when your making the function call to populate it.
Sure, I'll edit it into my question...
extarbags