4 Replies Latest reply on Feb 1, 2012 5:31 AM by RayCologon

    Exporting first 'X' number of records in a table

    stratlake

      Just wondering if someone could help me achieve this? I have a table with approx 5000 records that get generated, however I would like to only export the first 4000.

       

      Any help would be much appreciated.

        • 1. Re: Exporting first 'X' number of records in a table
          comment

          Show all records, sort them the way you prefer, go to record number 4001 and omit multiple records = Get (FoundCount) - 4000.

          1 of 1 people found this helpful
          • 2. Re: Exporting first 'X' number of records in a table
            RayCologon

            stratlake wrote:

            Just wondering if someone could help me achieve this? I have a table with approx 5000 records that get generated, however I would like to only export the first 4000.

             

            Any help would be much appreciated.

             

            Hi stratlake,

             

            A short script will achieve what you want. There are several ways to approach it, but possibly as good as any would be:

             

            • Go to Layout [ALayoutOfYourChoice]
            • Show All Records
            • Go to Record/Request/Page [First]
            • Omit Multiple Records [No dialog; 4000]
            • Show Omitted Only
            • Export Records [ ]

             

            There are some other options you might wish to add, such as choosing the export order, file type, name and path for the export (as attributes of the Export Records [ ] step), and you might consider having the script open a new window a the start and close it at the end, to avoid disturbing the user's found set and selected record - but the above should give you some ideas to get you started.

             

            Regards,

            Ray

            ------------------------------------------------

            R J Cologon, Ph.D.

            FileMaker Certified Developer

            Author, FileMaker Pro 10 Bible

            NightWing Enterprises, Melbourne, Australia

            http://www.nightwingenterprises.com

            ------------------------------------------------

            • 3. Re: Exporting first 'X' number of records in a table
              stratlake

              Worked perfectly - thank you very very much!

              • 4. Re: Exporting first 'X' number of records in a table
                RayCologon

                stratlake wrote:

                Worked perfectly - thank you very very much!

                 

                Hi stratlake,

                 

                That's great.

                 

                One small afterthought that you might want to consider... In the event that the script may ever be run at a time when there are less than 4,000 records in the table, an error will be returned when the Omit Multiple Records [ ] step tries to execute.

                 

                If that's a possible concern, you can code around it by adding an If[ ] and End If step, as follows:

                 

                • Go to Layout [ALayoutOfYourChoice]
                • Show All Records
                • If [Get(TotalRecordCount) > 4000]
                  • Go to Record/Request/Page [First]
                  • Omit Multiple Records [No dialog; 4000]
                  • Show Omitted Only
                • End If
                • Export Records [ ]

                 

                With the additional steps, you'll get the same result if there are more than 4,000 records, but if there are less, the script will just export them all (so in effect it operates to limit the size of the export to 4,000).

                 

                It might not be an issue for you, but worth mentioning in case.

                 

                Regards,

                Ray

                ------------------------------------------------

                R J Cologon, Ph.D.

                FileMaker Certified Developer

                Author, FileMaker Pro 10 Bible

                NightWing Enterprises, Melbourne, Australia

                http://www.nightwingenterprises.com

                ------------------------------------------------