Goal:
Display the text "All State-Province" instead of "All geographies" at the prompt list in SSRS
Problem:
I tried googling around and in the end I don't know how to solve it.
Information:
*Im using SQL server 2012
I don't use Report Server 2012, but in 2008 the following applies.
It depends on how you're populating your parameter,
If you're declaring the values in a list
Right click on the parameter, and change the label text.
or.....
If you're populating from a query then you need to ensure that the value you're using to populate the label returns "All State-Province" instead of "All geographies".
One way round this would be to set up a calculated field on the query used to populate the dataset
something like
=iif(Fields!LabelText.Value="All geographies","All State-Province",Fields!LabelText.Value)
Then use that field as the label.
I see your update..
What I believe you need to do, is set up a new calculated field on your GeographyStateProvince dataset
Call it NewLabelText.
Then use the expression
=iif(Trim(Ucase(Fields!ParameterCaptionIndented.Value))="ALL GEOGRAPHIES","All State-Province",Fields!ParameterCaptionIndented.Value)
Then as shown in my previous screen print, use the new calculated field instead of ParameterCaptionIndented
You can see your datasets on the left of this picture.
Related
I use the MS Access 2013 Expression Builder regularly.
But one thing I've never managed is simply to show only the first (say 25) characters of of a text field on the report.
It would seem to be a no-brainer. I've done far more complex things in Expression Builder without an issue. But shortening a text field on a report always return #Type! no matter how I try to adjust the expression.
It would seem to me that all I need is:
=Left([CompanyName],25)
But it just doesn't work! The report shows a #Type! error.
I can do this no problem by creating a RecordSet SQL string and setting the report RecordSource to it (with OpenArgs). But I can't manage it in Expression Builder.
What am I doing wrong?
When you build expressions for a form, then ANY column that exists in the datasource can be used - EVEN if not placed on the form.
However, reports have a significant difference. Your expressions ONLY work against data bound controls. In other words, the control has to be on the report (no doubt in this case in the details section of the report.
What this means is you have to drop into the details section (and you can and should use in design mode - add existing fields:
So, you need to add the Company name field to the report.
Of course you don't want it to display, so you can delete the label part, and set the control visible part = false. Eg: this:
Remember, you can't have the control reference its self.
In your case, the control you dropped "most" likely is called CompanyName, and then you changing the datasource expression to its self!!!
The other way?
well, you need to RE-NAME your control!!!
If you JUST drop the control onto the report, then its name will be CompanyName.
But, you NOW using =left(CompanyName,25) which POINTS to its self!!!!
So, as noted, you can drop in a company name control and then set visible = false.
The other way, is to CHANGE the name of the control to be DIFFERENT then the company name.
So, you can use add fields, but then in the other tab, rename.
So, say I just dropped in a Description column, but want to use left(10) on it
So, we do this:
Note VERY careful how I re-named the control.
I can't use left(Description,10), since that would refer to the VERY SAME control that I am attempting to use the expression against!!!
I would be saying, please use left of a control called description, but that description s the expression I am wanting to execute against!!!!
So, re-name the control. And now I can do this:
Note the arrow in above - note VERY careful how the control name is DIFFERENT then the data expression (Description) in this example.
Note VERY careful, I can now place OTHER controls on the report, and reference now:
I can reference Description in the expression, OR I CAN USE DescripitonLEFT in that expression!!!!
As you can see, we need a way to distinguish which control we are referencing here. In fact, some developers i have known as a habit NEVER use the same name for their controls vs the datasource of the control for this reason.
In your case the very same expression, and very same control BOTH have the same name - and thus you can't evaluate the expression of a left(Descripiton,10) against the VERY same control with the VERY same name!!!
So, you have to dis-ambiguate the name and the expression you want. In this case CompanyName. As noted, your left("some control") is the VERY same name as your current control.
Try just re-name of the control you dropped into the report.
Here's the crux of the question, I have 26 compliance queries to run, in a previous question it was suggested that I should filter a single query, or two, on a single report. I like this idea, and have rewritten the query to pull all available data from all the fields, this query works fine. The report will work fine as well, as it does with a model query that I had coded up beforehand. What I would like to do is this:
The end user is being given an interface in access that is locked down, I want them to click a button, and that button will run the query and send to the text box just the field that is called for.
I have tried doing this through VB using the where clause and aliasing the column being called, this did not work at all. I have the report currently pulling the correct data, but not displaying the dates along side it. But it is filtering correctly aside from that.
So what needs to happen is this : Button click : Query runs, and is filtered for "Compliance Issue 1" and puts the dates in "Compliance Issue 1" in the text box on the report.
Right now... I get a list of names, the correct list of names, but an empty column.
I have tried using OpenArgs, but all it did was fill in the date column with "Compliance Issue 1" not the actual data in that column.
Is what I am trying to do even possible in access, and if so does someone have a reference or suggested starting point.
My background : 6 Months of python coding, 3 months of SQL , and some limited access from 20 years ago.
As noted, using the filter of the openreport is without question the way to go (one would not write a whole bunch of different queries - you can send/have any filter for that report - you can EVEN use a sub query in the filter that you send to the report.
As for displaying values in the report that are not from "rows" of data?
There are two approaches that work quite well.
First up, is you have that launcher form. This of course allows the user to select critrea - maybe even some nice combob boxes. These selections take care and you build up the filter in code that you pass to the report.
As for text boxes to be filled out from that form and inclluded in the report?
If they are static values from the report (say filter options, or even just a notes box that you could type in some text? To display such values in textboxes on the report?
You can directly set the text box data source (in the designer) to the report propter form like this:
=(forms!MyPromptForm!notes)
So, any value you shove into text boxes on the report prompt form can thus be displayed in any text box on the report with the above type of expression. And it does not even take code to achieve this goal. So, you could say with above enter some notes into that text box, and thus on the report, whatever you typed into that text box will now show up in the report. You just drop in a text box onto the report, and set the data source of the text box to the above expression that references the form with the values we want from that form.
The next approach, and I often use this in the case that some value/expression/calculation has to occur for each row. In this case, you can use the reports on-detail format event. This allows you to run code for EACH row of data.
You are free to run ANY code in that event - and that includes after running such code to set a text box in the reports detail section.
So, say the query only had the Hotel ID (PK). This is a lame example, but you could then write this code in the on-format event of the reports detail section.
dim strSQL as string
dim rst as DAO.RecordSet
strSQL = "SELECT HotelName from tblHotels where ID = " & me.HotelID
set rst = CurrentDb.OpenRecordSet(strSQL)
me.HotelName = rst!HotelName
rst.Close
So in above, we assume that a row text box is called HotelID, and then in code we build a whole sql query from scratch, pulled the row data from a table, and then SHOVE/SET the value of the un-bound text box called hotelName.
As noted, the above is a simple example, but we are free to run any code we want, pull any data we want, and set the value of ANY text box for the given detail section ONE row of values.
So, above shows two approaches. The first approach is code free - and you can put forms! expression directly into the report, and the values from that report prompt form will thus show up directly in the report. However, if you need VBA code to run for each row, pull values, walk the dog, and THEN set a text box on that one details row of data, then you are as above shows free to write procedural code in the report that fires + runs for each row of data - and that means you can quite much do anything you want in terms of running code. I mean, even that on detail format event COULD pull values from your report prompt form, but as the 1st example shows, you can shove in forms! expression directly into a text box - and those forms! expressions can be values from a existing form that is open before the report is launched.
I am building an SSRS 2005 report using BIDS. My report filters on date. When the selected date returns no data rows the report is blank, just the title is displayed, no table or column heading.
How can I change this to display a message like No data available. or Report is empty.?
You could set the property NoRowsMessage available on the report's table control like this:
Select the Tablix control and press F4 to view the Properties pane.
Find the NoRowsMessage property and set the value to whatever message you'd like.
You can also to format the message using the Font and TextAlign properties.
Here are some examples of what the report will look like under various settings:
Further Reading: Here is a Technet article on how to Set a No Data Message for a Data Region
Avoid NoRowsMessage and build your own conditional empty row
One problem (or feature if that's what you want) with NoRowsMessage is that it'll literally replace the entire table with just a plain old message string.
Which provides a relatively counter-intuitive end user experience in my opinion. Normally when no data is found by a system, we'd like to know something about what data was being looked for and what it would have looked like.
Instead, based off how to keep the structure of the Tablix when there is no data to show, you can do the following:
Insert New Header Row, outside the group and above the details record.
Right click on the side of the new row and Set Row Visibility
Set Visibility to the following expression which will count the rows inside the current Tablix and only set Visibility to True if there is no data.
=CountRows() > 0
Optionally, merge the cells and add your own message or just display an empty row
Here's a comparison of how the various options will render: (pick whichever look you think best fits your data and use case)
Right-click on whatever databound element(s) you are using in the report and there should be a property NoDataMessage There are a host of options there but the Caption is the first element I would look at.
I'm new to SSRS. But I thought I had been given a simple task for my 1st request. I have a SSRS PO Report Form provided by our ERP software vendor. I only need to move the fields around to satisfy our users. I move a field from the middle of the page to an area near the top. With no other changes but when I try to run the report I get this error:
The Value expression for the text box ‘TextBox1’ refers directly to the field ‘PrintAs’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope.
I have 4 datasets in this report. They were there originally and have not been modified. To move the fields I am simply clicking on them till I get the 4 pointed arrow and dragging the field to the top of the report. Is there something under the covers that I'm missing? That needs to be changed when the field position is changed?
The object that textbox1 existed in was specifically linked to a dataset that contained the field PrintAs. I'm assuming it was a rectangle or table. You can only move textbox1 within the area of that rectangle or table or else you will see that error. If you move it outside of the bounds of that rectangle or table then you must use the LookUp function or an aggregate function in order to reference the field and get the correct value returned. What is happening in regards to the error is that the report is trying to return all the PrintAs Fields instead of just one which is causing SSRS to fail.
Is the PrintAs field exactly the same for every row in the dataset. If so you can you use this in textbox1 expression: First("Fields!PrintAs.Value,"*Dataset name*") and move the textbox anywhere you'd like. If the field is not the same you will need to use the Lookup function in the textbox to get the correct value
MSDN Lookup
I am building an SSRS 2005 report using BIDS. My report filters on date. When the selected date returns no data rows the report is blank, just the title is displayed, no table or column heading.
How can I change this to display a message like No data available. or Report is empty.?
You could set the property NoRowsMessage available on the report's table control like this:
Select the Tablix control and press F4 to view the Properties pane.
Find the NoRowsMessage property and set the value to whatever message you'd like.
You can also to format the message using the Font and TextAlign properties.
Here are some examples of what the report will look like under various settings:
Further Reading: Here is a Technet article on how to Set a No Data Message for a Data Region
Avoid NoRowsMessage and build your own conditional empty row
One problem (or feature if that's what you want) with NoRowsMessage is that it'll literally replace the entire table with just a plain old message string.
Which provides a relatively counter-intuitive end user experience in my opinion. Normally when no data is found by a system, we'd like to know something about what data was being looked for and what it would have looked like.
Instead, based off how to keep the structure of the Tablix when there is no data to show, you can do the following:
Insert New Header Row, outside the group and above the details record.
Right click on the side of the new row and Set Row Visibility
Set Visibility to the following expression which will count the rows inside the current Tablix and only set Visibility to True if there is no data.
=CountRows() > 0
Optionally, merge the cells and add your own message or just display an empty row
Here's a comparison of how the various options will render: (pick whichever look you think best fits your data and use case)
Right-click on whatever databound element(s) you are using in the report and there should be a property NoDataMessage There are a host of options there but the Caption is the first element I would look at.