I’ve made some label printing forms that print several different label sizes, eg. 40 labels / A4 page using a listview. I have been trying to find some way of getting them to print from a start point, so that they don’t need to use a fresh sheet of labels every time ( eg. if the current sheet is half used, printing would start from halfway down the page.). Is there some way of doing this?
The nearest I have come up with is to add the pre-calculated number of blank records to the start of a dataset and load that into the form. This works fine in the form display, but the print preview only displays the non-blank records. I did it like this:
var stocks = globals.printStocks.getColumnAsArray(1);
for ( i = 1; i <= globals.LABEL_start; i++) {
stocks.unshift('');
}
globals.printStocks = databaseManager.convertToDataSet(stocks);
controller.loadRecords(globals.printStocks);
I’ve also tried adding non-blank records, but again they appear fine in the form view but in print preview any duplicate stock ids don’t appear, and the records are reordered in order of the stock id.
Can anyone tell me why the print preview is showing something different to form view or suggest a better way for positioning the start point for label printing?
I suggest that you get rid of the array and try this instead
for ( i = 1; i <= globals.LABEL_start; i++) {
controller.newRecord()
}
then just do a sort that will put the blank records at the beginning. you wouldn’t need to load the records or convert a dataset into an array and then back into a dataset
I’ve tried creating new records, but it tries to create these in the database, which I don’t want, as I just want some dummy blank records in memory to shift all the real records into the right place on the page. Is there some way of using controller.newRecord to create records only in memory? Using the dataset method creates the right result in the form display, but it doesn’t work when I go to print preview. Is this because print preview has to have records that exist in the database and not just in memory?
Just to add to my last post, I forgot to say, using newRecord doesn’t work because it tries to create a record with no PK and so can’t save it, and it also gives duplicate record errors when there should be more than one blank record.
Thanks for the suggestion, - thats just what I’ve ended up trying. When I goto print it copies the foundset into a separate print table that has its own pk and so can accept null and duplicate values for my stocks.
So the print forms again displayed properly, but using this slightly different method. However I still had alot of trouble when going to the print preview. All the records appeared blank! I eventually got them to appear in printpreview as they do in the form by loading them in the form as a dataset from my own sql query. This is probably abit long winded, but I just couldn’t get it to work otherwise.
Anyway, thanks to everyone for the replies, I have certainly found this forum invaluable!