views:

1533

answers:

2

I have a report in SQL Server Reporting Services which should show

  • a text box with a static text for "normal" users
  • a text box with a hyperlink to open up a new details windows for "super" users

The user level is determined by a parameter being passed into the report.

How can I achieve this? I tried to create a textbox with a text span inside that has a hyperlink, and then just leave it blank for "normal" users, but that doesn't seem to work reliably.

Is there a trick or method to get this to work? I'm thinking I need to add some code to the report to check the user level and then either insert a static text, or a text with a label, into that target textbox. But how do I do that (not having any VB/VBA/VB.NET experience....)

Thanks! Marc

+1  A: 

I haven't got SSRS installed on the machine that i'm writing this on so i can't give you an exact guaranteed bug free answer, but this answer should set you on the right track.

Have two textboxes, both located in the same absolute position (inside a container element if necessary). Fill them both with their correct values. Then just control their visibility by toggling their Hidden property with an expression:

=(Parameters!UserLevel.Value = 'Admin')

Obviously UserLevel is the name of the parameter being passed in to the report. The 'Admin' value is for illustrative purposes, personally i would use an int value to represent the user level, much like using an enum.

Remember that it is the Hidden property you are setting, so you have to reverse the logic you would have used if you were setting a Visible property :)

slugster
Thanks, yes, I was thinking about something like that already. I'll give it a try
marc_s
+2  A: 

To make the hyperlink, you should be able to use an expression like

=iif(Parameters!IsSuperUser.Value = True, "http://some link","#")

in the Action property of the textbox, if you set the Action to "Jump to URL".

To control the content of the textbox, use a similar expression in the Value property.

(This is true on SSRS 2005 - I don't have access to 2008)

Edit

Unfortunately, hyperlinks in SSRS aren't formatted in a way to make it clear that they're hyperlinks. The only way to achieve this would be to add similar conditional formatting expression to the Color and TextDecoration attributes to make the field appear in a different colour and underlined when it is a hyperlink.

Ed Harper
OK, thanks for the hint - I'll try that and report back
marc_s
Hi Ed, your approach does work, thanks. My only gripe right now: if I am a super user, and my textbox really contains a URL to jump to - I don't really see that visually - the text doesn't turn into a "typical" hyperlink (blue with underline). Any way I can tweak that, too? (I was hoping setting the action to "Jump to URL" would accomplish this)
marc_s
Ed - thanks for your help - with your answer, I was able to get my stuff working. Thanks!
marc_s