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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Like" in reporting services

Status
Not open for further replies.

Stripes1283

Programmer
Jun 13, 2007
28
0
0
ZA
Hi there i need to create some sort of way so that a cell in a grid can be checked for a month name, if a month name appears then it needs to be bold.
I can do this with one month:
=IIF(Fields!txtDescription.Value like ("June*") , "Bold", "Normal" )

Now how can I do this with all the months in the year, does Like only take on argument, I have tried using "Or" and "And", but nothing works.

Please help would be appreciated.
Thanks.
 
Write a custom function in the code of your report. For example:
Code:
Function GetFontStyleIfMonth(FieldText As String) As String
  Dim RetVal As String = "Normal"
  If FieldText.ToLower.Contains("january") Or FieldText.ToUpper.Contains("february")....etc Then
     RetVal = "Bold"
  End If
  Return RetVal
End Function

Then call it in your expression like =Code.GetFontStyleIfMonth(Fields!txtDescription.Value)
 
Hi thanks, I have a better idea of whats going on now, pretty cool function though.
One problem though I have inserted the code into the code are under properties in custom code, thats fine.
Now when i try to add this:
=Code.GetFontStyleIfMonth(Fields!txtDescription.Value)
in the expression it gives me an error on the functionname, as if it doesnt exist. Maybe i have to do it different in RS2005, because when I type "=Code." the intellisense it brings up doesnt contain the function name. Any ideas, i have even changed the function to a public and a shared function.
Still not accepting the name.
Thanks
 
In 2005, the code dot intellisense doesn't work.

Here's how I've formatted my custom code.

Code:
Function GetFontStyleIfMonth(FieldText As String) As 
  If FieldText.ToLower.Contains("january") Or FieldText.ToUpper.Contains("february") Then
     GetFontStyleIfMonth = "Bold"
  Else
     GetFontStyleIfMonth = "Normal"
  End If
End Function
 
Yes don't worry about the red sqiggly lines when you call a code function. Just preview the report to make sure it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top