14 Replies Latest reply on Dec 31, 2014 3:09 PM by zmarketing

    How to select some records to print them



      How to select some records to print them


           Hi there, 

           I've been looking for this but I haven't find anything yet. 

           I'd like to know if there is any way to select which records I want to print (from the whole list of records or from a selection), like highlighting or marking them with a check box... So at any time I can choose which ones I want to print. 



        • 1. Re: How to select some records to print them

               There are multiple methods. The typical method used is to perform a find for the record or records you want in a given report. But other methods can be set up for selecting a record or records also.

               Do you want to be able to click to select multiple records or do you want to select and then print just a single record?

               Is this a database that is or might in the future be hosted over a network for access by multiple users?

          • 2. Re: How to select some records to print them

                 To make my question a bit more clear, I'm trying to be able to select multiple records from the main list or after the x found after performing find. To give you an example.. today I need to print records: 1, 4, 12, 34, 58... and tomorrow I will need to print records: 3, 35, 45, 65... This selection will be always quite random and impossible to perform using find. 

                 The database is already hosted in a NAS, accesible to multiple users. 


            • 3. Re: How to select some records to print them

                        The database is already hosted ... to multiple users.

                   This is a crucial detail. Many selection methods, such as adding a check box to the table to click when selecting a record would result in each user's selections interfering with the selections made by other users.

                   Here's how I would do it:

                   First, you need a field in this table that uniquely identifies each record--what we generally refer to as a Primary Key. I will refer to that field by calling it YourTable::PrimaryKey so substitute your names for mine if you choose to set up this particular solution.

                   Define a global text field, gSelectionList, in a different table in your database. Add this relationship:

                   TableWithGlobal::gSelectionList = YourTable::PrimaryKey

                   Set up a list view layout for listing the records that you want to select for printing.

                   Put a button in the body set to perform this script:

                   Set Field [TableWithGlobal::gSelectionList ; List ( TableWithGlobal::gSelectionList ; YourTable::PrimaryKey ) ]

                   Each time that you click this button, the PrimaryKey field's value is appended to a list of such selected values in the global field.

                   Then, to pull up a found set of just your selected records for printing, have a script do this:

                   Go to Layout ["TablewithGlobal" (TableWithGlobal) ]
                   Go To Related Record [Show only related records; From table: YourTable; Using layout: "PrintLayout" (YourTable) ]

                   This will pull up a found set of just your selected records on the layout you have set up for printing them.

                   Note 1: The changes made to the value in a global field are not visible to other users so each user can build their own list of selected records without their selections interfering with the selections made by other users.

                   Note 2: You can use the following conditional format expression to change the appearance of the button for selected objects in order to show which records have been selected and which have not:

                   Not IsEmpty ( FilterValues ( TableWithGlobal::gSelectionList ) ; YourTable::PrimaryKey )

                   This can even be used to make an "X" or "tick mark" disappear to mimic the look and function of a check box field.

              • 4. Re: How to select some records to print them

                     Hi there,

                     this is very helpful, but is beyond my knowledge of FileMaker Pro, and I've been having to decode each step. However, I've managed to reach the step "Put a button in the body set to perform this script", but the following script gives me the error "A number, text constant, field name or “(” is expected here."

                • 5. Re: How to select some records to print them

                       When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

                  • 6. Re: How to select some records to print them
                    How to select some records to print them

                    1. VIEW your records as a TABLE 

                    2. Press the plus sign after the last field to ADD A NEW FIELD

                    3. Call the field whatever you want. I called mine ACTION

                    4. Put any word (I used PRINT) in the new field, next to any record you want to print.

                    5. Do a FIND on the new FIELD called ACTION, for the word PRINT.  type "=PRINT" (no quotes) in the FIND box that comes up.

                    6. All the records you selected for PRINT show up on the screen.

                    7. PRINT the records using the "Records being browsed" option.


                    • 7. Re: How to select some records to print them

                      @John Arch - Phil covered that method, effectively, by pointing out that it wouldn't be suitable for a multi-user environment.  If two users are trying to create a printable list they will each affect the other's selection.

                      • 8. Re: How to select some records to print them

                        @Phil - very neat idea.  I use a more complicated version of that, purposely appending a leading and trailing return, as I think I need it to be able to truly mimic the Check Box function and have the record removed from the list if I have to un-check it.  Do you have a neat way of doing that?  (I run a PatternCount check of 'ReturnRecordIDReturn' in the existing global, add the RecordID if it isn't there, and parse and re-join the parts before and after if it is.)

                        • 9. Re: How to select some records to print them

                          I'm trying to do this same thing, with a multi-user environment. Would there be a way for a user to:

                          1. Select a record
                          3. Have selected record copied to a table
                          5. Print all the records from new table


                          I am basically one week old in Filemaker, so feel free to tell me I'm just way off base. 


                          <>>> UPDATE <<<>

                          Actually, I am starting to understand this to be exactly what @PhilModJunk is showing (I certainly could be mis-understanding, but I think I am understanding this correctly). Going to try to see if I can't actually implement this and will report back.

                          • 10. Re: How to select some records to print them

                            @PhilModJunk (and anyone else out there) how do I get the semi-colon there without typing it? I didn't type the first semicolon, but the second one I did and can't figure out how not to. I think this is my main issue -- referring to http://forums.filemaker.com/comment/294538

                            This is what I have right now:

                            • 11. Re: How to select some records to print them

                              Just a short note, as it is late, and I just can't write much right now. Phil's method is correct. It is the problem itself which is a bit more difficult than beginners will expect; but all developers will run into this eventually. His method used a global field to hold the IDs of the desired records; a global's data only shows for that one computer using it (and only while they are logged in). He uses the: List ( global field; ID field )* as a method to "add an ID". 

                              The global field is in a "Globals" table (with a 1 record only). This is a useful place to put such data (as well as other things). In this case it is especially useful, as you need a relationship from that global field (with the list of IDs) to the ID field in the real data table. That allows you to use a Go To Related Record script step to quickly go to the "marked" records of the real data. 
                              [ Notice that the real data records were not modified in any way; which preserves their "modified date" (or timestamp).]

                              * The List () function will automatically put together a "list" (separated by ¶, return), from fields; hence it will add ¶ then the ID or the record you click the script to run from.

                              An additions, which may be desired (later):
                              A method to remove an ID from the list (for "oops! wrong one").

                              P.S. OK, I wrote more than I thought. It may, however, not be very well written; I can barely read my own writing. A small file would be easier to understand. I will do one tomorrow, if no one does so before.

                              • 12. Re: How to select some records to print them

                                Threads more than three months old in this section do not automatically pop to the top of Recent Items when a new comment is posted to it and this will not be noticed by many people visiting the forum. It's best to start a new thread with a link to the original so that more people will see you comments and questions.

                                If you read my original post on Set Field again, there is only one semi colon in that example, the one separating the "Target Field" and "calculated result" parameters. You cannot type in that semi-colon so if you try, you get a syntax error. The semi colons that are part of the calculated result expression--such as the terms listed inside the List function can and must by typed in.

                                • 13. Re: How to select some records to print them

                                  I was meaning to create a file earlier; but I had to do "grandchild" watching first :-/

                                  This is a small file I did. It shows the "Mark" calculation field, visible as a [x] checkbox [ which means its Value List has ONLY a 1 in it ]. It looks and works like you would expect, however, in real life, it is NOT a plain regular field. It is also Unstored, and cannot be Indexed, as it is looking at a global field (which has the list of IDs).

                                  I made a change from Phil's method. I did not use a 2nd Globals table, to hold the global field of the list of IDs. It did not seem necessary. I used a "self-relationship" (of the main table) instead. It comes to the same thing. It also requires a relationship.

                                  The Mark [x] field calculation can be used for a Find to get the records for printing (or anything else).

                                  I also added two more scripts. One to Clear all Mark [ ] checkboxes (basically, clears the global field, hence clears ALL records, even those NOT in the Found Set.*

                                  The other, All [x], would set all records (in the current Found Set to [x].

                                  * Yes, this "Clear" could be narrowed down to just the Found Set; but that would require something like a Loop (or a Custom Function). Also, it seemed to make sense to me to set [x] "only within the found set", but "clear all marked [x], whether visible or not". It's questionable.

                                  OK, I added another script, to do the Clear for only the Found Set. It uses a Loop, and it just goes thru the records; it will not be fast if you have a found set of thousands. There are faster methods, but more complex. [ Personally, I'd use a Custom Function.]

                                  [ I added another script, to do the "clear all 'Mark [x]' within found set", but using a Custom Function, 'AntiFilterValues'. This would be faster than the "standard' script, which runs a Loop. You need FileMaker Pro Advanced this CF to your file(s).

                                  I also added some short steps in both the above scripts, to Exit Script if the global is already empty.]


                                  • 14. Re: How to select some records to print them

                                    @Fenton Jones:

                                    Thanks a bunch for that file. I've been trying to work through it and think I understand it, but when I try to do it from scratch I get an error that says:

                                                                                 This action cannot be performed because the required table is missing.

                                    I've been reading @PhilModJunk's thoughts on this (the required table is missing) but probably need a little more time to absorb it.