SSRS Row Number Function Not Working in PDF - reporting-services

I am using the below code to add a Row # column in my report:
Dim row AS integer
Public Function GetRow() As Integer
row = row + 1
return row
End Function
When running the report, the report returns 29 rows and the row column seems to be working perfectly, labeling all rows 1–29 in the preview. However, when I export to PDF, the rows in the report change from 30–58. I have no idea what is causing the issue.
Is there something that the PDF is doing that handles the function differently? Does the PDF even use the function?
If not, then what can SSRS be doing that causes the function to rerun when exporting?
Why can't SSRS just export what I see on my screen?

If you want to just display the row number you can use SSRS function. just put this code in your tablix column in which you want to display row number.
=RunningValue(Fields!ProductId.Value, CountDistinct, "{name of dataset}")

I'm not sure why your function isn't working correctly, but there's an easier way. SSRS has a built-in RowNumber keyword. You should just be able to put the keyword in the table with the dataset you're using in parenthesis as a parameter of the function.
=RowNumber("yourDatasetHere")
You could also use =RowNumber(Nothing) to specify that the function should use the outermost dataset used in the table.

I've run into an issue where my alignment was off on PDF but was fine elsewhere. I had to put page breaks using =Ceiling(RowNumber(Nothing)/37).
That might not be what is causing your issue, but for me, when I forced a finite number of rows on each page, it fixed it for me. Sometimes I've had to group things, or do things that didn't make sense to fix it.

Related

Looping in SSRS Report Tablix

Recently, im come across the situation where i've to loop through each rows in the Tablix Like :
Foreach(rows in Tablix)
{
//Operation
}
But i dont think its possible.
So, is it Possible to Loop through the Rows inside Tablix?
My Problem Which made me do that is :
I've an tablix where a Column contains the : First(Rs!Field) inside the Row Group
And, In the last Row outside the Group i want to Sum(First(Rs!Field)), mean,
I want to Sum, First Only Field from the each Row Group.
But its not possible with SSRS. I even cant sum up the Sum(Reportitems!textBox.value) inside the Tablix.
Thats why i come accorss that situation.
I know there is no Solution for the Above, that why, I was thinking about if there is any Looping Statement Available.
I'd even tried the Function Code to Set and Get the Values Like :
Public Shared Dim Total as Double
Public Function SetTotal(ByRef val)
{
Total=Total+val
}
Public function GetTotal()as Double
{
return Total
}
But, this way, If i Scroll to the Pages Forth and Back, each time it sum up the values to the existing.
Hope you understand. I've tried everything possible i think.
So, please let me know, if there i can achieve any looping Functionalities?
Thank You in advance.
I've added the Pictures :

Access report prints multiple pages when text box control source is using a multi-value field from a table

The Access 2010 report i have has a text box that uses a multi-value field from a table for its control source. I know multi-value fields in tables are bad but its what i have to work with at the moment.
The problem i am having is that even though its only a two page report when i physically print it or do a print preview i get more then 2 pages. So if the multi-value field has (2) values i will get (4) pages total with the same information basically (2) copies.
How can i prevent the report from printing a copy for each value?
Ok so I will answer my own question now that i have found a work around.
I found a work around that will let me print only the pages i want (ie the first two pages or one copy not several)
In my macro instead of using RunMenuCommand PrintObject that just prints the report.
I created a vba function
Function cmdPrint()
DoCmd.PrintOut acPages, 1, 2 //acPages, start_page, end_page
End Function
and used this function from the macro using RunCode cmdPrint()
Now I only get one copy not several. Like I said its a work around but it works for me and i hope that it will help someone else someday with the same problem.

Reporting Services displays #Error if no rows to display.

I'm creating a rather simple report with Reporting Services and noticed that if my data source (which is XML / Web Service) returns no rows, I get #Error text in the text cells that contain some formatting or aggregation logic. It displays one row + the totals row with all datasource cells empty except for the aforementioned calculated ones.
Any idea how I can get rid of these messages?
One thing you can do is set conditional visibility on the details row accessing the "Hidden" property.
=IIF(CountRows("DataSetName") = 0,true,false)
Another thing you can do is check the fields "IsMissing" property before setting it.
=IIF(Fields!Item.IsMissing,"",Fields!Item.Value)
You need to do data validation within each of those cells to make sure something is not blank. It is erroring because it is trying to do a calculation on a blank value. Try:
=IIF(IsNothing(Fields!Item.Value),"",Do Calculations)

stuck in microsoft report

My report is containing some null value.
Report is generated through query
In my report I am calculating sum of every field for that I had written =iif((field name) is null,0,sum(field name))
Through this function I am getting result as 0 only if field contains some value as well
I agree with Remou, you should be using the footers for totals. However if you wanted to carry on with the way you are doing things then try replacing the IIF with NZ(MyField,0)
You should put that IIf statement in the query for that (or those) fields that you want to avoid nulls on. That way you can just put the Sum function in the details section of the report with impunity (assuming details section here).

SUM() on a form footer resulting in #Error

I'm trying to display the sum of a field in a text box in the form footer. The field is not calculated in any way.
Here are a couple of the things I've tried:
=Sum([txtWeldInches])
=Sum([WeldInches])
=Sum(CDbl([txtWeldInches]))
=Sum(CDbl([WeldInches]))
...well you get the idea. Each iteration I've used results in the Text Box displaying #Error Without exception.
I've used similar constructs in different forms in the same project, so I'm not sure what the problem might be.
Has anyone run into this before?
EDIT:
I ended up writing a VBA routine to update the boxes when it was likely that they would be changed rather than trying to get a bound sum() function to work.
http://support.microsoft.com/kb/199355
All of the domain functions are based on the same query (over the underlying recordset). If one of the bound functions on the form has a binding error, all of the functions on the form will return an error.
In other words, make sure all your footer controls are resolving properly and not hitting any nulls.
If you use a SUM or AVG then make sure you are also using the Nz function:
ControlSource = =SUM(NZ([FIELD],0))
Is the field "WeldInches" existing in the data source for this form?
What datatype the field "WeldInches" is?
EDIT: I have looked at all your comments. If it doesn't work by databinding, try and use the unbounded way. At runtime, get the value of WeldInches using DSUM and set the footer textbox's value when the form loads.
Also, remember to update it at places where you think the SUM could change.
I had the same problem as Rister.
The source of the form was an underlying query.
I had a bound text box named txtQty on this form. Its control source was Qty (based on the underlying query of the form).
I created an unbound text box and entered =SUM([txtQty]) and received an error.
I tried various ways to find a solution and was very desperate.
Then I deleted the underlying query and created a new one using the same name and fields as before.
Then I entered =SUM([Qty]) into the unbound text box on the form and voila, it worked. Note that I didn't enter the name of the bound text box (txtQty) into the expression, but its control source (Qty). I don't know why, but it worked for me.
I know you said "Form" but for those who have issues with the Sum formula in an Access "Report" the formula has to be in the Report Footer NOT the Page footer. Took me a while to figure it out as Access defaults to only showing the page footer.
You want to sum by the name of the column in the record source: SUM([WeldInches])
Make sure there are no other textboxes with the name WeldInches.