SSRS Code is Setting for the next group - vb.net

I'm having this issue where my SSRS Report header will show me the value of next group of the report. I am using the Code route to accomplish this. I have two functions, one to set the Value, and one to retrieve it. This is inside the code section of my report.
Public Shared varInvoiceNum As Integer
Public Function SetInvoiceNum(InvcNum As Integer) as Integer
varInvoiceNum = InvcNum
End Function
Public Function GetInvoiceNum() as Integer
Return varInvoiceNum
End Function
I then have a textbox with an expression that sets the value in the header of the group for Invoice Num. This group only shows Once and cant have it repeating, as it contains address information. In the Report Header is where I call the get function.
The problem occurs when the total section for the report appears on the second page. For whatever the reason, even though the header section in the tablix that contains the Set function call never reappears until the third page. On the Second page the Second Invoice Number will appear. Even though its still apart of the first group. It some how gets set to the next value. Any idea how this might be happening?
EDIT: The Second Invoice number in the batch shouldn't be showing, because the Total section is still apart of the First Invoice group. This is the Issue, there is no error message. It just improperly sets the next variable to the next group when the Set Expression hasn't occurred again.

Related

Get values from a particular row using Custom Code SSRS

i have a report with parameter is the year i can select a multiple value: for example i selected 2005,2006,2007
when i click in view report i get this result
i added some custom code to add value in arraylist
Dim values As System.Collections.ArrayList
Function AddValue(ByVal newValue As Integer)
If (values Is Nothing) Then
values = New System.Collections.ArrayList()
End If
values.Add(newValue)
End Function
Public Function GetArray(Item as Integer)
return values(Item)
End Function
i added my code in my matrice this is the result
The first row i got the right anwer but the other rows are false answers this is the resut what i need
Without RDL details regarding your expressions - it is difficult to answer your question. What are your expected results? What is the exact input and output you are expecting? Please provide samples.
In this scenario, it seems the issue is in your custom code. Once you return the result at the end of first row. The variable(called "result") keeps the "66" and it was never overwritten so that it always shows "66". In Reporting Services, it generates cells from left to right, top to bottom. So you need to pass the first column (HP, DELL, Acer) as argument in your function and use a variable (called "previous")to receive this value. Always do the judgment at the beginning of the function, if the passing argument is not equal to the "previous". You need to clear the "result" variable.

Problems with Report Variables

I'm new to SSRS 2012 and have a question about variables. I have a report that retrieves order and order line information from our database (order #, order line #, item, quantity, etc). I need to add a textbox to the footer of the report that can only be displayed for certain items (i.e. if item # equals "123" then show textbox, otherwise hide it.
I added a report variable called 'ItemExists', and unchecked the read-only flag, and set the default value to 0.
I then added an expression to the textbox on the report footer to show it if variable=1, and to hide it if variable=0.
I'm trying to add a textbox with an expression to the body of the report (same group as where the item # is displayed), but I'm unable to get the report variable to update properly. Here's what I tried:
=IIF((Variables!ItemExists.Value = 0) and (Fields!item.Value = "123"), (Variables!ItemExists.SetValue(1)), Nothing)
This works if the value of the item is 123, but if the item is not equal to that value, it still sets the ItemExists variable to 1.
The reason I'm checking to see if the variable is equal to 0 is that there may be multiple lines in the report, and if any one of the items is a match, I want the variable to be set to 1.
I'm not sure if I'm way off track here, but if you could provide any assistance on the best way to achieve this, that would be great.
Thanks in Advance.

Report Page Footer Sum Error

In Design View of a report I have this
In the fourth column, those two "=SUM([SUM...." text boxes both say "=Sum([SUM660201])". The column name is "SUM660201".
On the Report View however, only the first text box (the one in the detail and not in the page footer, correctly calculates the sum). In the Page view, it says "#Error" rather than "257.71"
I want the sum to be calculated in the Page Footer, not in the Detail. How do I make the sum in the Page Footer Work?
From here
The page footer and header sections, however, do not support calculated controls that use aggregate functions such as Sum
You can however use VBA to calculate page aggregates. The linked MS article explains how. The summary of their instruction is this:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then
txtPageSum = txtPageSum + ExtendedPrice
txtPageQuantity = txtPageQuantity + Quantity
End If
End Sub
Access increments [the PrintCount] property by one whenever the data for the current section is printed. Because there are times when the Print event for the Detail section for a particular record might be called more than once, checking the PrintCount value ensures that you don't add the same value twice to a page total.
Reset the numbers for the next page print
Private Sub PageHeaderSection_Print(Cancel As Integer, _
PrintCount As Integer)
txtPageSum = 0
txtPageQuantity = 0
End Sub
Again, see the MS help page for more details.

Can display dialogue with function, but cannot set variable with function

I want to take the return value of the function getProjectTag().
tell application "TaskPaper"
tell front document
repeat with the_entry in entries
-- For each entry, get the data from TaskPaper
tell the_entry
set project_name to getProjectTag(the_entry)
I get the error:
TaskPaper got an error: item 26 of every entry of document 1 doesn’t
understand the getProjectTag message." number -1708 from item 26 of every entry of document 1
However, when I replace:
set project_name to getProjectTag(the_entry)
with:
display dialogue my getProjectTag(the_entry)
it shows me a dialogue of the correct return value -- so the function is working correctly.
Stupid me:
set project_name to my getProjectTag(the_entry)
fixes the problem.
I wasn't aware of what my did.

SSRS - How to check all rows in a table?

I have a table in a report and a textbox that changes its background color based on the value(s) in the table. Right now I have the background color expression for the textbox set to:
=iif(Me.Value = ReportItems![NewValue].Value, "Yellow", "Transparent")
"NewValue" is the name of one of the columns in the table. The above works fine if the textbox value is in the very first row in the "NewValue" column, but not otherwise.
How do I fix this so it will work if the textbox value shows up in any row in the "NewValue" column?
Sorry, I'm a little new to Reporting Services and haven't seen any functions for table controls.
Instead of ReportItems![NewValue].Value, you can also use ReportItems("NewValue").Value, by the way
I finally got this working yesterday thanks to this blog post:
http://mpasharp.spaces.live.com/blog/cns!5BA71A558863C810!191.entry?sa=340192646
I basically did what he did in the post, modified slightly for my report. I also added a function for getting the row index of the value I was looking for (variables are a little different in mine).
Public Shared Function GetChangedValueIndex(txt As String) As Integer
Dim counter As Integer = 0
For Each s As String In ChangedValueList
If s = txt Then
Return counter
End If
counter += 1
Next
Return -1
End Function
The other caveat is that calling the function to add a value to the array has to occur earlier in the report than anywhere you want to check for it. The table I was working with is actually at the end of the report (and can't be moved for requirements reasons) so I made a copy of that table, moved it to the top of the report, and set it to be hidden.
Unbelieveable that there isn't an easier way to do this.