The simplest option is to get a "one label at a time" label printer such as the DYMO. (This is the brand that I see the security guard at FileMaker Headquarters use to print visitor badges when I attend the digFM group that meets there...)
But method 1 is your best bet for this. But I'd modify that approach to use a separate "labels layout" linked in a one to many relationship to your table of data that you want printed on the label. A script can create one such record for every label you want to print and ask the user how many labels have been used on the first page in order to create that many new records in the labels layout. Sorting can then make these the first records in your found set in order to account for the unused portion of your layout. SInce you are now using a separate table, your script can delete the entire found set when done and your original table is left unmodified thorughout the process.
PS. this method also enables you to print multiple copies of the same label if such is needed.
I've always used method One... add X number of blank records... sort (blank records appear at the begining) print and then delete the blank records. Never had any issues.
The potential issues are that you can end up with a bunch of blank records in your table and you have to clean them out by deleting records. A mistake here, either by a user or the person setting up the script can be a problem. By moving this to a related table, you protect the integrity of your original table plus gain the ability to print multiple copies of the same label by creating multiple records linked to the same record in the original table.
There can also be some chance of getting a label stuck up inside your printer when you feed a partially used label sheet into a printer--a potential risk that varies a lot from printer to printer and user to user..
Thanks. My database is already getting confusing enough, so I just created a layout that lets us start in the second column (by setting an extra wide margin in the Layout Setup), and modified my "print mailing labels" script to work in this layout as well.
I was hoping for more of a setting in the print dialog (as with how you can print records being browsed, current record, or blank record) but I can see that the use case for such a feature would be pretty narrow.
So I ended up setting up a way to not only create labels that start anywhere on the page, but also specifying a number of repeats of each label. This is in a different database from my OP. In the present case it's not envelope mailing labels but labels for boxes so I want to put labels on multiple sides of the boxes.
It was a bit harder than I thought (though I am also doing some other verification of the underlying data), but it was fun. I'm not sure if it's exactly what PhilModJunk suggested, since no sorting is required, but here's what I did:
- Using the original layout "Boxes", I designed my labels on a new layout, BoxLabels using FMP's convenient New Layout wizard. Note: the Boxes table has a field called BoxID (a unique ID for the box, using serial numbers). If the BoxID is 0000, everything on the label hides. Otherwise it pulls the data from the Boxes layout; there's no need to copy over all the data from every field.
- I then created a new table, BoxLabels, with a single standard field, BoxID, which I connected to the Boxes table with a relationship of BoxID = BoxID.
- I did have to add the table name to text fields in the labels layout (e.g. replace <<BoxDate>> with <<Boxes::BoxDate>>)
- I created two global fields: StartOnLabelNumber and HowManyRepetitions. The first one indicates how many labels have been used on the sheet (plus one, so it's more clear what needs to be entered to use it), the second is how many times each label is to be repeated.
- A script run from the Boxes layout creates a variable, $BoxList, which is a comma-separated string of labels to generate based on the current records, starting with repetitions of 0000 for the blanks and looping until it's gone through all records. The logic* is actually much simpler than I thought it might be. The variable ends up looking like: 0000,0000,0000,1234,1234,2345,2345,3456,3456 (the first three spaces are blank, then the three labels with IDs 1234, 2345 and 3456 are each printed twice).
- To create the labels, the script then goes to the BoxLabels layout, deletes all records, then creates new records with BoxID of the first four characters of the string, strips off the first five characters, and repeats until $BoxList is <6 characters long.
*The logic for encoding the $BoxList variable, including adding blanks at the start and repetitions is simply:
If ( not IsEmpty ( $BoxList ) ; $BoxList & "," ; "" ) &
If ( $~NumberofBlanksLeft > 0 ; "0000" ;
This then followed with steps to decrement the variables:
If [ $~NumberofBlanksLeft > 0
Set Variable [ $~NumberofBLanksLeft ; Value : $~NumberofBlanksLeft - 1]
Set Variable [ $~NumberofRepetitionsThisLoop ; Value: $~NumberofRepetitionsThisLoop - 1 ]
...followed by this If statement to allow the same number to be encoded the set number of times:
If [ $~NumberofRepetitionsThisLoop = 0 ]
Go to Record/Request/Page [ Next ; Exit after last ]
Set Variable [ $~NumberofRepetitionsThisLoop ; Value: BoxLabels::HowManyRepetitions ]
The logic to decode the list does not need to care what the value is, it simply takes the first four characters of the string and spits it out into the Box ID. (I have other measures to ensure that the BoxID is exactly four characters long)
The HowMany Repetitions and StartOnLabelNumber global fields get set to 1 in my FileOpen script, and the latter can be an integer between 1 and 10 (the number of labels on a page).