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)
 How to check all rows in a table for a value?

Author  Topic 

dgundersen
Starting Member

3 Posts

Posted - 2009-10-06 : 17:48:18
In a report I have a table and a textbox that changes its background color based on the value(s) in the one of the columns of the table. Right now I have the background color expression for the textbox set to:

=iif(Me.Value = ReportItems![NewValue].Value, "Yellow", "Transparent")

"NewValue" is the name of one of the columns in the table. The above works fine if the textbox value is in the very first row in the "NewValue" column, but not otherwise.

How do I fix this so it will work if the textbox value shows up in any row in the "NewValue" column?

dgundersen
Starting Member

3 Posts

Posted - 2009-10-07 : 13:30:48
I'm a little surprised no one knows how to iterate over table rows. Is this something not commonly done??
Go to Top of Page

dgundersen
Starting Member

3 Posts

Posted - 2009-10-08 : 16:52:41
I finally got this working yesterday thanks to this blog post:

http://mpasharp.spaces.live.com/blog/cns!5BA71A558863C810!191.entry?sa=340192646

I basically did what he did in the post, modified slightly for my report. I also added a function for getting the row index of the value I was looking for (variables are a little different in mine).


Public Shared Function GetChangedValueIndex(txt As String) As Integer
Dim counter As Integer = 0
For Each s As String In ChangedValueList
If s = txt Then
Return counter
End If

counter += 1
Next
Return -1
End Function


The other caveat is that calling the function to add a value to the array has to occur earlier in the report than anywhere you want to check for it. The table I was working with is actually at the end of the report (and can't be moved for requirements reasons) so I made a copy of that table, moved it to the top of the report, and set it to be hidden.

Unbelieveable that there isn't an easier way to do this.
Go to Top of Page
   

- Advertisement -