5 Replies Latest reply on Aug 4, 2015 12:38 PM by isamudysan

    Hide, Show, and Count

    isamudysan

      i have a couple of questions in hopes that answers will steer me into the right direction. 


      first inquiry is this:


      is there way via scripting or SQL that i can hide previous records and just show the current record? for example, when we open up a FMP file that has data on it, we usually see entered records from the previous date and the dates before that.  what i like to see, then, is when i open the FMP file there would be no showing of previous records, but only a single new record waiting to for me to make the entries.  of course, i do have a Date field so i'm thinking that there might something about hiding previous dates and just show the current date.


      second inquiry, and related to this is:


      i want to count the total records for the current date, and not previous dates.




      much appreciate it, and thank you very much

        • 1. Re: Hide, Show, and Count
          cortical

          run a startup script to find date = Get(current date)

          test for found count = 0 and create a new record and stamp current date if count = 0

           

          set the status script to run on first open

          this is under File> FileOptions > Script Triggers, on first window open.

          (assuming you are using a recent FMP version)

           

          count current date is the found count when finding date = Get(current date)

          set  a global field for display on the layout

          may need a commit to force the display

          • 2. Re: Hide, Show, and Count
            CarstenLevin

            OK: You want to start on the layout of one of your tables with a found set of 1 and this 1 record should be a new record just created for you now.

             

            The advice by Cortical is nearly correct, but has two problems.

            • If you are opening your database for the second time the same day it will still show some records if you or other people created new records earlier today.
            • There is a good chance that you will end up creating a lot of empty records, unless you always and always and always open your database with the purpose of entering a new record. This is due to the fact that the script proposed by Cortical is creating a new record every time you start your database.

             

            Consider one of the following solutions

             

            A do as Cortical suggest, with two modifications

            On open create one new record and then display just this record (thereby also omitting other records created today).

            Create a script running when closing the last window ... deleting empty records in the database (thereby getting rid of all the records that was not used).

            I do not like this approach with the creation of a lot of records that may or may not be used.

             

            An alternative solution: A start layout

            Create a startup layout with two buttons + keyboard shortcuts. Browse or Create New record. Thus letting the user choose what she want to do.

            Thereby avoiding creating a lot of unused records.

             

            Best regards

             

            Carsten

            • 3. Re: Hide, Show, and Count
              isamudysan

              Carsten and Cortical, I thank you both for your replies and I like both replies and or solutions.  I will give it a shot, and see where it leads me.

              • 4. Re: Hide, Show, and Count
                siplus

                the "we usually see" in your original post suggests that the solution is multi-user.

                 

                The "records created today" request, as you described it, is NOT taking into account the multi-user aspect.

                 

                Define exactly what should happen when n users open the database in the morning, then we can maybe come up with better quality answers.

                • 5. Re: Hide, Show, and Count
                  isamudysan

                  siplus, you are correct....lol...just got a bit excited. but, yes, there will be only 2 users using the file as they are "auditors" or QAs (Quality Assurance) to make sure that what they had tested and checked either passes or fails.

                   

                  Carsten's reply of:  "If you are opening your database for the second time the same day it will still show some records if you or other people created new records earlier today" is perfectly fine as long as yesterday's date or previous dates are not shown.

                   

                  As with Carsten's concern of "Create a script running when closing the last window ... deleting empty records in the database (thereby getting rid of all the records that was not used). I do not like this approach with the creation of a lot of records that may or may not be used " is also a concern of mine as well.