8 Replies Latest reply on Dec 17, 2012 11:27 AM by brian.curran

    Copying Dates into other fields...

    brian.curran

      Title

      Copying Dates into other fields...

      Post

           Hi,
           We log the dates and times when we visit a customers premises to carry out work.

           Called at = Date and Time
           Arrived at = Date and Time
           Departed at = Date and Time

           The majority of visits happen on the same day so we are typing/selecting the same date, three times for one visit log. What I would like to do is enter the date in the field for Called at and then have that date automatically copy across to the other two fields.

           As we work 24 hours a day, we would also need to be able to amend the Arrived at or Departed at Date fields if required. Could this be done with a Set Field step?

           Thanks
           Brian.

        • 1. Re: Copying Dates into other fields...
          philmodjunk

               Yes, it can be done with a set field step. It can also be done with an auto-enter calculation on the second and third fields. Put a reference to the first field inside the calculation expressions for the second and third fields. Leave the "do not replace existing values.." check box selected and these two fields will copy the initial value of the first fields when the user enters it, but will remain fields that you can edit to enter different dates/times as needed.

          • 2. Re: Copying Dates into other fields...
            brian.curran

                 Hi Phil, I already have the following in the "Calculated value:" section


                       

                 Let ( digits = Filter ( Self ; "0123456789" ) ; /*excludes all other characters*/
                 Case
                 ( Length ( digits ) = 6 ; Left ( digits ; 2 ) & "/" & Middle (digits; 3 ; 2 ) & "/" & Right ( digits ; 2 )
                 /* date */ ;
                 Self /* error, don't modify user input */
                 ) /* ends case */
                 ) /* ends let */
                  
                 Is there a way to combine the two separate things?
                  
                 Thanks
                 Brian.
            • 3. Re: Copying Dates into other fields...
              philmodjunk

                   IS this a field of type date, time or timestamp? It should be, NOT text.

                   Then the above code is not needed--there is built in validation that will capture errors of this type before this auto-enter calculation can have any effect on "fixing" data entry problems.

              • 4. Re: Copying Dates into other fields...
                brian.curran

                     The field is set to Date and I've replaced the 'formatting' string with a reference to the previous date field. This bit works fine, typing a date into the first field results in the same date appearing in fields 2 and 3.

                     I don't quite follow what you mean with 'built in validation', if the date that appears is 17/12/2012, I would like users to have the ability to overwrite it with another date by typing 161212

                     Is this still possible?

                     Thanks
                     Brian.

                • 5. Re: Copying Dates into other fields...
                  philmodjunk

                       IF you enter data into a date field, filemaker automatically pops up an error message if the data that you enter--such as 161212 is not a valid date. I would expect that error message to pop up before the auto-enter calculation has the chance to modify the data to turn it into a valid date. But maybe I am working from an incorrect assumption here.

                       There are ways to script that kind of data entry via the OnObjectValidation trigger as this trigger is tripped before any data validation is performed.

                  • 6. Re: Copying Dates into other fields...
                    brian.curran

                         That's right, the FM error message pops up straight away if I type 161212. It's odd but the string shown below allows 161212 to be entered and formats it correctly on other date fields elsewhere in the db but I couldn't get to work in this one.

                          

                         Let ( digits = Filter ( Self ; "0123456789" ) ; /*excludes all other characters*/
                         Case
                         ( Length ( digits ) = 6 ; Left ( digits ; 2 ) & "/" & Middle (digits; 3 ; 2 ) & "/" & Right ( digits ; 2 )
                         /* date */ ;
                         Self /* error, don't modify user input */
                         ) /* ends case */
                         ) /* ends let */

                         It doesn't matter now, as I've had to replace it with the reference to the first Date field but I will need to look into a script for the OnObjectValidate method you mention...

                         Thanks
                         Brian.

                    • 7. Re: Copying Dates into other fields...
                      philmodjunk

                           I would guess then that they aren't fields of type date, but are fields of type text as this auto-enter calc strictly manipulates the date as text, not a date value.

                      • 8. Re: Copying Dates into other fields...
                        brian.curran

                             Ah, my mistake again!

                             They are Date fields and they do have that string in the Calc field but they also have a script trigger OnObjectValidate that does the actual date formatting. I never thought to look there due to seeing the string!

                             Thanks
                             Brian.