How to set a value to a label using formula depending on the number of pages the report got printed on ?(Crystal reports) - vb.net

I want to set label value to 'Red' if a group in a report is only on one page, and 'Green' if the group requires 2 or more pages. Is there a way to detect if {field1} (group header text) has continued to the next page or ended on the same page? I have been trying this in the formula editor of the label. No luck yet.

There's a built-in function named "InRepeatedGroupHeader". Combined with the Previous function you could detect wether a group is repeated due to a page break or not. CR function with pseudo column name:
If
InRepeatedGroupHeader
And
Previous({GroupingField}) = {GroupingField}
Then // this group header is repeated due to page break
'yes'
Else // this group header is either not repeated or is repeated due to group change
'no'
This may be of use in your case, though it does not allow detecting "groups filling more than one page" on the page a group starts.

Related

PageNumber / TotalPages on group header in report .rdlc

I have a .rdlc report where I have no header (I have group headers)
I want to put the PageNumber on the group header.
If I use Globals!PageNumber I get this error:
The Value expression for the textrun 'Textbox12.Paragraphs[0].TextRuns[3]' refers to the global variable PageNumber or TotalPages. These global variables can be used only in the page header and page footer
Is there any way I could do this?
If there is no possibility to put this data on a group header...is there any possibility of overlap a header with the group header on a same line?
Global variables can't be used outside of the header/footer, as there is no relationship between the header/footer and body areas. Therefore, there is no easy and precise way to display the page number in the body area.
However, as suggested by user Raymond-Lee in the second link, you can try to calculate it yourself by dividing a given row number by the total number of rows per page (and adding one if the page number will always be the first row). Nonetheless, this would take a bit of effort.
First you need to have the Page Header/Footer showing, then you can add items to it. To show it, right click in the pale yellow area of the Layout view. Then select Page Header and/or Page Footer, this will create another section on your report where you can add items. Or, you can go to the Report menu option and enable the Page Header/Footer from there.
link

SSRS Code is Setting for the next group

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.

qtp unable to call proper Action depending on the input from excel sheet for "yes" status

I'm trying to call some Actions depending the "Yes" status and using Column names, e.g Login, Header,Footer etc. as below sheet (link)
Below is the code: (skipping the excel load and other part) and Action for each Column name are present e.g Login, Header, Footer etc
iRowCount= DataTable.GetSheet("Main").GetRowCount()
iColumnCount=DataTable.GetSheet("Main").GetParameterCount
For iR = 1 To iRowCount
DataTable.SetCurrentRow iR
bRun=Datatable.Value("Run","Main")
If UCase(bRun)= "YES" Then
For iC = 5 To iColumnCount
bComponent= Datatable.Value(iC,"Main")
If ucase(bComponent) ="YES" Then
sModule=DataTable.GetSheet("Main").GetParameter(iC).Name
print sModule
RunAction sModule, oneIteration
End If
Next
End If
Next
Even though the Footer in second row is not "Yes" still the action is been called
I have use Print Statement to show the Action names
the output is
Login
Header
Footer
SecondaryNavigation
Login
Header
Footer
SecondaryNavigation
However when i dont use
RunAction sModule, oneIteration
then the output changes to
Login
Header
Footer
SecondaryNavigation
Login
Header
Cookiemessage
SecondaryNavigation
I'm not able to find out what is wrong, when i don't call the actions, the code works fine, however when i use Action call to execute, it follows the 1st row status not the 2nd row status
You have hidden column C.
So the index for the "footer" column actually is 6, not 5.
So your loop should iterate from 6 to column count, not 5.
Experience from many many IT years in the Windows field: Keep looking for Excel columns with width = 0, or you will waste your life looking for bugs which are in reality missing information or wrong column assumptions :O
Even though the Footer in second row is not "Yes" still the action is
been called
This is because actually, due to the quirk just outlined, the "Header" cell value is being used, and it is "Yes" for that row.

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.

How do you print specific pages in Cognos using conditional variables

I have five letters (five pages) in a Cognos report. The letters are in response to NSF checks received by the company . Each letter is different based upon conditions that exist in the NSF file. I need to print those letters based on those condtions. For example -- if the customer I has never had an NSF check. I want to print a nice letter ( page 1). If the customer has had other NSF check then letter 2 ( page 2 ) and so on. I have created the following variable --
IF [Main].[RETURN_REASON_CD] = 'FINAL' Then '1' Else (
IF [Main].[RETURN_REASON_CD] = 'FIRST' AND [Main].[METHOD_OF_DRAFT_OVR] = 'ACHDA' Then '2' Else (
IF [Main].[RETURN_REASON_CD] = 'FIRST' AND [Main].[METHOD_OF_DRAFT_OVR] <> 'ACHDA' Then '3' Else (
IF [Main].[RETURN_REASON_CD] NOT IN( 'FIRST', 'FINAL') AND [Main].[METHOD_OF_DRAFT_OVR] = 'ACHDA' Then '4' Else '5')))
What do I need to specify in values 1,2,3,4,5 to get this to print correctly. Thanks
I suggest you create five boolean variables, then go to the page explorer, click on the Report Pages folder, which will then show you a list of your five pages. Click on each of your pages and set the Render variable.
When the Render variables evaluates to TRUE, your page will be rendered. When it's false it will not.
There is probably a way to do this using one variable as you have done but I can't think of it right now. You might want to look into page sets. Or you could compress all the pages into one page and use a conditional style to hide each piece.
You can use a single page with a conditional block, so you only need one string variable with five different values instead of five boolean variables.
Create one variable that has a case expression like yours...
Case
When Expr 1
Then "Show Page 1"
When Expr 2
Then "Show Page 2"
etc...
else "Show All Pages" or whatever you want to do with your else
End
You need to make sure the literal values are listed exactly as output values on the variable page. This is important.
Start with report page 1 and switch to structure view that way it is easy to navigate up to the Page object. Once your in the page object i believe there is a render variable and/or conditional style depending on your Cognos version. If it is a render variable its easy... you just select that variable that you created and choose which literal values will trigger a render true condition. So if your on Page 1 then you will pick Page 1 as the true condition from the variable and the page will only be rendered when that condition is true.
If there is not a render variable then you will have to navigate to the variable pane after it is created and one at a time choose your output values and that will take you into condition mode (Changes color). When you have say "Page 1" selected in the condition explore you will navigate to Page 1 via the structure view and set visible = property to true and then navigate to all other pages and set them false(You could default all pages to false initially save this step if you want).... You will repeat this exercise for all possible output values. Won't take long but it is more tedious and that is why they created the "Render Variable"
The condition explorer allows you to select a output value and then navigate around in the report and change style visibility properties... those styles/visibility properties will only happen when the variable condition finds that output value true. It is a visual if/case statement basically.