4 Replies Latest reply on Mar 28, 2014 10:39 AM by JennyArntzen

    Auto Enter Last Visited endtime into New Record startime



      Auto Enter Last Visited endtime into New Record startime


           Hi Everyone,


           I am a long time Filemaker developer (self taught) and new to this forum. I am looking forward to being part of the community!


           I have been looking everywhere for a way to get the endtime field from my previous record to automatically input into my startime field in my new record. I want to set up Auto Enter Last Visited to bring data from the endtime field and put it into my new record startime field. Has anyone figured this out? Any suggestions would be much appreciated.

        • 1. Re: Auto Enter Last Visited endtime into New Record startime

               Will the record for the previous visit always be the previous record in your found set at the time that you enter this data? If so, you can set up an auto-enter calculation using the GetNthRecord function to copy data from the preceding record in the found set.

               A more reliable method that does not require that the record for the previous visit be the preceding record in the found set is to use a relationship that matches only to the previous visit record. The details for setting that up will depend on the current set of tables and fields involved.

          • 2. Re: Auto Enter Last Visited endtime into New Record startime

                 Thanks for your reply!

                 The application is a time tracking system for remote inputs by workers on site. The current problem I am addressing is simply having the endtime from the previous record Auto Enter the new record as I am inputting batches of records into the system. Ideally, I want to set up the system so workers in the field, inputting from their ipads or iphones, see only their entries, and when they hit New Entry, the endtime from their previous record automatically shows up in their startime field.

                 So there are two parts to the question, the most immediate problem is just getting the endtime / startime data to carry forward from one entry to the next. Later, when I have site workers logging in with personal usernames and passwords, I am hoping they will only see their own records and the same function will work for them.

            • 3. Re: Auto Enter Last Visited endtime into New Record startime

                   Both methods that I have described briefly will work--especially when a user has a sorted list of only their records and they then create a new record. The first method is easier to set up, but it's more likely to copy over a value when you don't want it to as it is very easy for any user to manipulate what records are currently present in a found set and in what order they are sorted. (We can use Manage | Security to keep them from accessing the records for other users, but they can still do a lot of different things with a found set of just their records.)

                   Thus, I prefer the second method over the first.

                   Let's say that you have a two tables: Employees and TimeRecords linked in this relationship:


                   Employees::__pkEmployeeID = TimeRecords::_fkEmployeeID

                   We can then add a new Tutorial: What are Table Occurrences? of TimeRecords,  name it TimeRecords|Prev and link it in like this:


                   TimeRecords::_fkEmployeeID = TimeRecords|Prev::_fkEmployeeID AND
                   TimeRecords::__pkTimeRecordID > TimeRecords|Prev::__pkTimeRecordID

                   You can then doubleclick the relationship line between TimeRecords and TimeRecords|Prev and specify that TimeRecords|Prev be sorted by __pkTimeRecordID in descending order. This makes the previous time record by a given employee the "First" related record in TimeRecords|Prev.

                   Then you can set up the starttime field to use either a looked up value or auto-enter calculation (see the auto enter tab in field options) to copy the value of TimeRecords|Prev::EndTime.

                   For an explanation of the notation that I am using, see the first post of: Common Forum Relationship and Field Notations Explained

              • 4. Re: Auto Enter Last Visited endtime into New Record startime

                     This is very helpful. I am going to look up your notation link, and start using those naming conventions. I am definitely on a learning edge to implement this idea, and I will try to replicate your instructions in a test database first to see if I can follow them to the letter before trying to modify them into my system.