Bold the particular text in SSRS - sql-server-2008

I have one column in my stored proc which contains following data:
abcs,defs,CA(5,6);wsdf,kdh,CA(7,8)
Now I want only data in brackets to be bold and else everything regular, like so:
abcs,defs,CA(5,6);wsdf,kdh,CA(7,8)

Create a custom code function to bold the text: right-click on a non-design part of the report surface, choose Report Properties... and click the Code tab. Enter the following code:
Function BoldText(Text As String) As String
return Text.Replace("(", "(<b>").Replace(")", "</b>)")
End Function
Go to your field cell and change the expression for the value from just the field value to calling this function with the field value:
=Code.BoldText(Fields!FieldToBold.Value)
Now, this bit is the key - in your cell, click on where it shows <<Expr>> so it is highlighted then right-click it and choose Placeholder Properties.... On the General tab select the radio button to activate HTML - Interpret HTML tags as styles.
Now anything between the brackets will be bolded.
Update - changing the font colour
You can also change the font's colour by using the <font> HTML tag (the following example makes anything between the brackets red and bold):
Function BoldText(Text As String) As String
return Text.Replace("(", "(<font color=Red><b>").Replace(")", "</b></font>)")
End Function

I believe you'll need to use placeholders to accomplish this.
Here's! an excellent tutorial.

Related

SSRS Font Color Using Wildcard parameter

Hi I have a report that i used a wild card search parameter so that i can pull record that contains a certain text.
For example: I need to search for subscription for Mary Johnson so on the keyword search box i just type "John". This set-up is working fine, but now I need to color that search keyword when found for each row. so i need assistance on expression code that mimics SQL syntax of LIKE in SSRS expression. I started to change the font color with =iif(Instr(Fields!ReportRecipients.Value)=Parameters!Keyword.Value,"Maroon","Black"), but it didnt work.
Please advise.
Sample
TOJo.eger#m.com; ruth.tuker#m.com;sandrae.espe#m.com; dan.gay#m.comIncludeReportTrueRenderFormatPDFSubjectDaily Report for IBC Medicare? was executed at #ExecutionTimeIncludeLinkFalsePriorityHIGH"
You can use some .net string functions directly in SSRS expressions. In your case you can use the Contains() function like this.
=IIF(
Fields!ReportRecipients.Value.Contains(Parameters!Keyword.Value),
"Maroon",
"Black"
)
If you are dealing with HTML and only want the search term to be highlighted then you can simply use this as the Value expression. You must leave the text box color properties as default.
=REPLACE(
Fields!ReportRecipients.Value,
Parameters!Keyword.Value,
"<span style=""color:red;"">" & Parameters!Keyword.Value & "</span>"
)
Finally, right-click the placeholder, choose properties and select Mark-up type as HTML
In this example, I used a country list and searched for the word "land", here's the results. The first column just uses the first method I described. The second column adds HTML tags.

Microsoft Report Designer Line Through Text when value not Empty

Has anyone used LineThrough text on Microsoft Report Designer within the expression value?
Example:
=Switch(Fields!a.Value is Nothing, "text here".LineThrough, Not(Fields!a.Value is Nothing), CStr(Fields!a.Value))
I need the "text here" to be strikethrough if a.Value is nothing.
You need to use an expression to show the value you want and then Harry's answer to set the LineThrough.
You can simplify your SWITCH statement for the value like this..
=SWITCH(
Fields!a.Value Is Nothing, "Text Here",
True, Fields!a.Value)
or if the expression will not get any more complex than you have then use IIF
=IIF(Fields!a.Value Is Nothing, "Text Here", Fields!a.Value)
If you need only part of the textbox then the easiest way is to use placeholders. These act almost the same way as a textbox but you can have several placeholders in a single cell/textbox each with it's own properties.
To add a placeholder click the cell/textbox first to get focus then right-click before or after any existing text/placeholders. Select Insert placeholder and set the expression as you wish, you can also format the placeholders font/color/decoration etc.
As an example I've got a small dataset with country names. If the country contains the word "Island" then I show different text and change the text decoration on one of the place holders. In the design you can see there are 3 placeholders, some text then a field then some more text.
When I run this I get the following output.
I've set strike thru on the countrydesc field placeholder but you can do the same on a text placeholder. You still have to do it in two parts, and expression to set the text value and an expression in the placeholders font properties to set LineThrough
You can set the condition on the Font/ TextDecoration on the selected report Item. There is an option for LineThrough.
For Example
=iif(reportitems!Textbox7.Value = "Cartons","LineThrough","Default")

Putting code in a text box (MS Access)

I am using a textbox for the header of my report, and based on what the user selects it will be "Baseline 8", "Baseline 9", etc. What I would like to do is have the text box coded so whatever number the user selects is entered into the text box. I managed to do it by using two text boxes, one just says "baseline" and the other text box says "=[Forms]![Navigation Form]![NavigationSubform]![Combo21]" and it will enter the correct value. But what I want to do is put it all in one box, and when I put "Baseline =[Forms]![Navigation Form]![NavigationSubform]![Combo21]" in the text box it doesn't work, it just leaves the code as the header when I generate the report. Is there something I'm not doing correctly?
First of all, when you state that a "textbox says", you really mean that "the Control Source property of the textbox equals." For a textbox (and some other controls), the value that you see on the actual form IS the Control Source property. I am not being picky for its own sake, rather it is important to recognize what value you are editing.
The Control Source property can essentially contain two types of values. The first is without an equals sign and it indicates the name of a field from the form Record Source. In that case, it binds the control to the field directly so that it automatically loads from the field and saves changes back to the field.
The second type of value always starts with =. It is a VBA code expression and can include calls to functions and other VBA operators. In your case, you want to concatenate (i.e. combine) two strings: one literal "Baseline" and one pulled from an access object [Forms]![Navigation Form]![NavigationSubform]![Combo21], so you need to use the string concatenation operator &.
="Baseline " & [Forms]![Navigation Form]![NavigationSubform]![Combo21]

SSRS Hiding Text in Footer

On my SSRS report I want to hide a page footer if none of the rows returned meet the condition where I need to show the footnote. I have a list of names and on the report I add an asterisk to indicate a certain condition for that person. For example:
Smith, Sally*
I have a footnote that says something along the lines of:
*Employee needs updated form on file
I am using the Visibility option of the Text Box Property to add an expression to hide the text in the textbox of the page footer if none of the employees have an asterisk after their name. (No sense in showing the footnote if it does not apply to anyone on the report.)
I've seen some examples here and thought this would work (setting false to not hide the text if an asterisk is appended to the name in the dataset):
=IIf(Fields!Name.Value.Contains("*"),False,True)
I don't get a syntax error but the footnote does not show no matter what I do with this expression or similar ones I have tried. I saw one place that said you cannot use a expression to hide the text in a textbox in a page footer but could not confirm this is true.
Is it my syntax or that fact that one cannot hide text in a textbox on a page footer? The option is not grayed out so it seems this should be possible.
This formula doesn't lookup a results set.
It only checks the first row: if the first row contains asterisk you will see footnote.
You can try to solve this for footer such way:
Create report variable "Has asterisk"
Create function at report code:
Public Function CheckAsterisk(ByVal CheckString As String) As String
If CheckString.Contains("*") Then
Report.Variables!HasAsterisk.Value = True
End If
Return CheckString
End Function
Call function from textbox where you display person name:
=Code.CheckAsterisk(Fields!Name.Value)
Check report variable at footer

How do I substitute one entry for another an MS Access report?

I recently started working with MS Access 2010, and I am trying to generate labels from a form that I have created. In the form, three pieces of information are put in by the user: style, color code, and unit of measure (UoM). The style numbers appear the same way on the form and in the report, and I have been able to get that to work.
However, for the color code, I need both the inputted color code and the actual color to show up on the report. I have a table that has all of the color codes with the corresponding color names. I cannot figure out how to get the text box that is supposed to show the color name to show it. I know virtually no SQL, but I found information on it on the internet and pieced together this code in the ControlSource for the text box the color name is supposed to be in:
=(SELECT [Description]
FROM [Color]
WHERE([Forms]![Box Label Form]![ThirdJoined]=[Color]![ColorCode]))
[Description] is the name of the column within the [Color] table that gives the actual color name.
[Box Label Form] is the name of the form.
[ThirdJoined] is the name of the input text box within the form.
[ColorCode] is the name of the column within the [Color] table that gives that color code.
This code doesn't work, and only results in #NAME appearing in Print Preview view. How can I get this to work, either code-wise or otherwise?
You cannot set the ControlSource of a textbox to a SQL statement. You could set it to a DLOOKUP function to lookup a single value. You also need to separate out the reference to the form control using concatenation (&).
=DLOOKUP("Description","[Color]","ColorCode='"&[Forms]![Box Label Form]![ThirdJoined]&"'")
I'm assuming the Color is a text-value so the form-value needs to be enclosed in apostrophes.
If this expression is used on the form [Box Label Form] then you don't need to qualify the name of the Control:
=DLOOKUP("Description","[Color]","ColorCode='"&[ThirdJoined]&"'")