Programmatically repeat "Detail" section in Active Reports - activereports

I need to repeat a "detail" section, simply repeating the data found in XML, based on the value of one of the XML elements.
Example:
I have a shipped quantity on a line item of 18. There is only one set of data for this in the XML, it is not repeated 18 times. I would like it to display this data 18 times.
Is there a way to programmatically repeat a section? I'm a total novice and i figured for once I'd ask here instead of going to the software vendor, in which case i learn nothing! I tried pouring over the 800+ page manual and couldn't find an answer.
Any solution where I'm not just repeating the detail section is of course welcome!
The report is coded in VB.net, my dataset is XML.
Thanks in advance!
Shawn

I understand your requirement and as per my understanding you wish to repeat the data in the detail section depending on the value of the 'Shipped Quanity'.
If the value is 18, the details section should be repeated 18 times and if ofr the next record the value if 5, the entry for this record should be dispalyed in the report for 5 times.
A cleaner to implement this without repeating the Details Section of the report would be to make use of a subreport.
The flow of the implementation would like the following :
Add a subreport in the Detail section of Report1 (Main Report)
Set it's datasource and add the fields you wish to display
You may remove the ReportHeader/ReportFooter of the subreport and set the height of the PageHeader/Footer to zero
In the Format event of the Detail section fetch and save the value of the 'Shipped Quanity' in some variable (say count).
On the basis of this value,
a. either repeat the Detail Section (number of times=value of count) of the Subreport
b. or render the Subreport multiple times (number equivalent to the value of count)
Regards,
Mohita

I ended up using a counter system and LayoutAction (which i didn't know existed before making this question)
The code ends up looking like this:
int counter = 1;
int skip = 1;
public void Detail_Format() {
if (skip == 1)
{
string convert =((TextBox)rpt.Sections["Detail"].Controls["txtShipQuantity"]).Text.ToString();
counter = int.Parse(convert);
}
if (counter > 1)
{
rpt.LayoutAction = LayoutAction.PrintSection|LayoutAction.MoveLayout;
counter--;
skip = 0;
}
else
{
rpt.LayoutAction = LayoutAction.PrintSection|LayoutAction.MoveLayout|LayoutAction.NextRecord;
skip = 1;
}
}
Thanks!
Shawn

Related

Auto select an option from a dropdown after a certain date

I'm creating a lost&found log for work, I have a dropdown list with options like "Collected", "Sent to guest", "Donated" etc.
I'd like to have the sheet automatically select 'Donated' after a certain date (maybe after 1 month) IF an option hasn't already been selected.
E.G. If somebody inputs a found pair of gloves on Nov 2nd, The empty dropdown will automatically change to 'Donated' on Dec 2nd unless somebody already selected another option (E.G. 'Collected').
You can accomplish this by either making use of Apps Script to check the conditions and make the corresponding changes or by directly implementing Sheets functions.
Sheets Functions
You can achieve the desired outcome by putting this formula on each status cell:
=IF(TODAY()-D4>30,"Donated","")
It will work as intended, the cell will not display anything until there are 30 days between the TODAY() date and the date provided in the D4 cell. If there are, the cell will display Donated. If another option from the drop-down is selected, that will erase the formula and only the new value will be displayed.
However, this method is more of a quick hack than an actual robust solution, as several things can go wrong. For instance, if an option from the drop-down is chosen by accident and then it is left blank again, the method will not work anymore for that line as the formula will have been permanently erased.
You can read about how TODAY() works here.
Apps Script (recommended)
The following script will check that, for every row in the sheet, both the status cell is blank and that subtracting the DATE FOUND is more than 30 days (unfortunately that has to be done in milliseconds).
function myFunction() {
var spreadSheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadSheet.getSheetByName("Sheet1");
sheet.getLastRow()
var range = sheet.getRange(4,1,sheet.getLastRow(), 7);
//SELECT A RANGE WITH THE 7TH FIRST COLUMNS AND AS MANY ROWS AS NECESSARY
//(WE ARE INTERESTED IN DATA STARTING FROM ROW 4TH)
var values = range.getValues();
var millisecondsIn30Days = 30 * 24 * 60 * 60 * 1000;
for(var row = 0; row<values.length; row++){
var status = values[row][6]; //STATUS IS THE 6TH ELEMENT IN THE ROW ARRAY (COLUMN G)
if(status == "" && (new Date() - values[row][3]) > millisecondsIn30Days){
//MORE THAN 30 DAYS AFTER FOUND
sheet.getRange(row+4,7).setValue("DONATED");
}
}
}
Of course, that script can be run manually or the job can be automated with an installable trigger that runs, for example, every month. You can read more about how to set up such triggers here.

MS Word mail merge: MERGESEQ and MOD

Field codes:
Data:
Expected result:
Actual result:
I was thinking about where I should tweak the codes to fix the issue that the first column of each has three records as other columns do.
Also, a new class name (i.e. 1A, 1B) should be added to the second sheets (i.e. the second and fourth pages).
Thanks in advance for any help!
You need something more like this:
There were two problems - a change of class causes a page break, so at that point you can't rely on on the { =mod({ MERGESEQ },3) } = 0 to show you the right place to break next. Because a column break can also cause a page break, you also have to keep count of the columns to ensure that you can insert the class name every time you have a new page.
An advantage of doing it this way is that you can easily change the number of columns and rows per page.
(I have put one other thing in there, because strictly speaking you need to initialize Class1 when you start the merge).

Crystal Reports - Hide Page Header on First Page

I have a report that needs to show a report header on page 1, and a different header on subsequent pages.
This seems simple enough; if I add pagenumber=1 and goupnumber=1 to the suppress formula for the second header, it will only be shown after the first page. However, the report is also supposed to reset the page count several times in a single group, thus leaving several pages that match those criteria.
Is there another field in Crystal reports that could have a unique value for the first page? Or is there another way I might go about solving this?
You have to specify in the Selection Expert - Suppress Formula the following formula:
PageNumber = 1
In the Supress Formula try this Formula
Drilldowngrouplevel = 1 ;
or
PageNumber=TotalPageCount
You have to specify in the Selection Expert - second header - Suppress Formula the following formula:
PageNumber <> 1

Crystal Reports: Suppression is hiding records on the next page

I have a Crystal Report where I want to display only the first ItemNum row.
I used the following expression (?) to suppress subsequent records.
Previous ({ItemHistory.ItemNum}) = ({ItemHistory.ItemNum})
My problem is that when I use a parameter selecting only one ItemNum, the same ItemNum on the second page which I want to appear (because it belongs to a different storeroom) will also be suppressed.
I figured it out. I just added check to make sure supression of the ItemNum on the next page (new storeroom) is not performed.
Previous ({ItemHistory.ItemNum}) =
{ItemHistory.ItemNum}
and
Previous({ITEMHISTORY.STOREROOM}) =
{ITEMHISTORY.STOREROOM}

Do GWT CEllTables have a 15 row limit?

I have a little piece of code which populates a CellTable from a
Type by adding the table as a DataProviders DataDisplay and by
using the DataProviders list to create a ColumnSortHandler and
corresponding Comparators... so each time the user clicks next I
populate the table in this manner with the next set of data. It all
works great apart from when the number of elements in my set of data
is greater than 15. In this case only the top 15 (ordered) elements
are displayed I.E. only 15 rows of the CellTable are visible within
the VerticalDialog. Is this a default somewhere or can I configure
this row limit. I've looked around my code and I can see places where
I have instantiated a list and this will default to 10 elements but 15
has me baffled.
I can provide code but thought this would jog a memory without the
need for boring old code.
Many thanks
Tony
This is a default yes: http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/user/cellview/client/CellTable.html#CellTable()
Constructs a table with a default page size of 15.
You can change it at any time with setPageSize or setVisibleRange.
Adding to Thomas Broyer answer. I always use the code below passing my CellTables/CellLists when I don't want pagination.
public static void setupOnePageList(final AbstractHasData<?> cellTable) {
cellTable.addRowCountChangeHandler(new RowCountChangeEvent.Handler() {
#Override
public void onRowCountChange(RowCountChangeEvent event) {
cellTable.setVisibleRange(new Range(0, event.getNewRowCount()));
}
});
}