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
Related
I'm quite new to VBA and I've been looking around but cannot seem to find a solution to my problem.
I have made a navigation form (frmNavigation) with 3 buttons, each referring to a different form, let's call them frm1, frm2 and frm3. In the navigationform the control buttons to switch between tabs are all named differently (btn1, btn2, btn3), but the subform that shows either frm1, frm2, or frm3 has the same name: “NavigationSubform” (this shows a different form depending on which tab is clicked on, based on the 'navagation target name' referring to frm1, frm2 and frm3).
When I want to refer to a textbox (txtBox1) on form 1 (first tab) and insert a value i can do this by:
Forms!frmNavigation!NavigationSubform.Form!txtBox1.Value = "insert awesome text"
But how would I refer to txtbox10 on the second tab (frm2)? Just using the following does not work:
Forms!frmNavigation!NavigationSubform.Form!txtBox10.Value
You then get the error 2465 (can't find the field).
I’ve been trying many different things, but can’t seem to get it right. So how do I refer to a textbox on a different tab than the first one?
Help us much appreciated!
Only one subform can be loaded at once. So you've just got to break this process into two steps.
Store the value from txtBox1 somewhere outside of the NavigationSubforms (a textbox on the parent form with visible = no, a global variable or a table works).
In frm2's On Load event, set txtbox10 to be the value you stored.
Just note, that you will need to add conditions in the On Load event if you want to avoid that textbox being set to an empty string or a wrong value if you have a setup where your filter is changing.
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]
I want to display page wise sum of 2 columns in footer.for that I am using following expression in footer
=Sum(ReportItems!col1.Value) + Sum(ReportItems!col2.Value)
but it gives following error
"The Value expression for the textrun refers to more than one report item. An expression in a page header or footer can refer to only one report item."
anybody knows how can I solve this issue and display page wise sum in footer ?
Thanks
Here is simple workaround for your problem:
Add single textbox to the body of the report and name it i.e. "SUM"
Add your expression to this textbox =ReportItems!col1.Value + ReportItems!col2.Value
For this textbox set visibility as hidden
In the footer refer to this hidden textbox using =ReportItems!SUM.Value
I usually use Custom code-feature of report for these operations. Just open Report Properties and choose Code-view. Just then write basic VB get/set-methods to save and sum values.
Referring to methods in TextBox expression goes just like this: =Code.[YourMethodNameHere].
For example, saving value:
=Code.SaveMyValue(Fields!MyVal.Value)
and getting value:
=Code.GetMyValue()
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.
This question was very helpful, however I have a list control in my report, and when the report grows over 1 page, data in the header only shows up on the last page of the report.
Apparently, hidden textboxes have to be on every page of the report for header to function properly. How do I do that? The only control I have in the list is a textbox with bunch of text that grows way over 1 page.
Although SSRS does not allow us to use DataSet fields in page headers, it allows us to refer to report items. So we could place a textbox (that takes its value from a DataSet field) anywhere in our report's body and set its Hidden property to true.
Then, we could easily refer to that textbox in the page header with an expression like: =ReportItems!TextBox1.Value and we are done. Note that the textbox that is being referred should be present on every page, or otherwise the header will print an empty value.
sExchange website to the rescue!!!
All I needed to do is to use Report Parameters with queried values from my dataset; and then reference =Parameters!Name.Value in the textbox in the header of the report.
Select Report Parameters, Add new parameter and check hidden, allow null and allow blank value.
If you are retrieving the values from database:
Under Available Values:
check "from query" radio button and provide dataset,value field and label fields.
Under Default Values:
check "from query" radio button and provide dataset,value fields.
Now provide the value for text box in the footer/header as =Parameters!Footer.Value (Footer is the parameter name).
the hidden text boxes can be placed within a rectangle that was a repeatwith property set to be your list item.