1 2 Previous Next 25 Replies Latest reply on Feb 27, 2016 10:09 AM by Jtmwalk

    Auto complete dates (Month + Year)



      Auto complete dates (Month + Year)


      I am using Filemaker to move on from a previous (very) old database and have the particular need to maintain a functionality existing in the currently used databases. The functionality is the auto-complete of date fields with month and year value, when the user types only the day.

      This is a very useful functions for databases used daily where dates modified normally belong to the current month and year. 

       I have figured out that Filemaker does the auto-complete of the year on a data field, providing the configuration is correct. Is there a way to make it auto-complete also the month? I can imagine that this would be possible with the use of functions  with calculated auto-enter or validation of the fields, but I do not know how I could program this...

       Is there any ready made solution for this?

       Any help would be greatly appreciated, specially since I am not an expert developer and do not dispose of unlimited time to conclude this work.

      Thank you in advance!

        • 1. Re: Auto complete dates (Month + Year)

          I would make it simple by adding a calendar button at the end of the date field. The user just clicks the calendar to insert a full date into the field.

          You can add it in layout mode; choose the field and (in FileMaker 11) in the inspector choose Data, then in the Control Style drop-down menu choose: Drop-down calendar.

          Hope this helps.

          • 2. Re: Auto complete dates (Month + Year)

            How would you know which month to auto-enter? Would it be the current month? (Just checking to be sure).

            If you are using FileMaker 11, you can use the OnValidate script trigger to create a script that auto-completes the month and year with the current month and year or a specified month and year if you want, though Jonna's suggestion is much easier to implement so I wouldn't try using a script trigger controlled script for this unless there's a really major need for it.

            • 3. Re: Auto complete dates (Month + Year)

              Thank you for your answers!

               In my case, given that most people using the database are very used to using keyboard shortcuts, I believe the best solution for me really is the script. I had also found the drop-down calendar, but this implies normally the use of the mouse, hence my post here...


               Phil, could you point me towards a tutorial that would teach me how to program this script in detail? Or maybe you can give me some more direction on how to do this?

              • 4. Re: Auto complete dates (Month + Year)

                I have so far managed to assign an "OnObjectValidate" for the given date field (currently formatted as text) and have assigned the "Insert Current Date" script step to this de-activating the options for "Select entire contents" and "Go to target field". The result I am getting with this script is still not the desired.

                In simple terms, what I need is a script that transforms for example:

                a user entry "02" during the month of December



                But I do not want it to transform a complete "01/12/2011" into the current date, for example "02/12/2011".


                This means that I should need something of an if statement to verify if the data entered is in the correct format (i.e.: dd/mm/yyyy) and if not, to auto-complete it by adding the current month and year data and applying the correct format, whilst maintaining the user entry as the day of the month.

                Can anyone help me on creating such a script?? I am completely stuck on this point after having gone through the tutorials and whatever online related topics I could find...

                • 5. Re: Auto complete dates (Month + Year)

                  You are using a database, so you're creating new records. Wouldn't "Auto enter creation date" solve this?

                  • 6. Re: Auto complete dates (Month + Year)

                    Or, instead of a script use "Get ( CurrentDate )"?

                    • 7. Re: Auto complete dates (Month + Year)

                      Hi Jonna,

                       This would not work, because people are introducing data in a monthly basis, normally just before the end of the month, hence auto-entering the current date does not help...

                       I suppose that this could be useful if on field selection, the day-part of the date would be selected and the remaining month/year date remained unselected... Can you think of a way of doing this? ( I only know the option of auto-selecting complete field content on field select, through the inspector...)

                      • 8. Re: Auto complete dates (Month + Year)

                        I do not know how to use this command... "Get ( CurrentDate)"... Can you explain how do you use this? I cannot find this in the script steps list...


                        But I have a feeling that this will simply include the complete current date, which is not what I am looking for... Am I right?

                        • 9. Re: Auto complete dates (Month + Year)

                          Yes, "Get ( CurrentDate )" is for today's date. I don't know of a way to select only a part of a date field.

                          I have a feeling the best way is a calculation, not a script. Sorry I couldn't help.



                          • 10. Re: Auto complete dates (Month + Year)

                            Thank you in any case Jonna. I must dig into the calculation functions then... Do you know of a tutorial or how-to guide for advanced calculation programming?

                            • 11. Re: Auto complete dates (Month + Year)

                              FileMaker help (the menu) has quite a lot of material. I recommend. Calculations are very powerful, and can be used with scripts (and vice versa).



                              • 12. Re: Auto complete dates (Month + Year)

                                Luis, are you still interested in the scripted approach? It's not the simplest script in the world, because as you have found out, it has to examine the data entered and only supply the missing parts if they were not already typed in. Let me know if you still want it and I'll then post an example script.

                                • 13. Re: Auto complete dates (Month + Year)

                                  Hi Phil. Yes, I am still very interested in the scripted approach and was in fact going through the manual and try to build up a script myself but it is a long painfull process for me as I am not familiar with the available functions and variables... If you could give me something as an example, it would really help me move forward... Thank you in advance!

                                  • 14. Re: Auto complete dates (Month + Year)

                                    The cool part about OnObjectValidate is that it trips a script before the validation rules kick in so that you can use a script to "fix" the problem before it can trip the error dialog.

                                    Let's say your field, Date, is defined in a table called "Table".

                                    Set Variable [$DateText ; Value: Getastext ( Table::Date ) ]
                                    Set Variable [$DelimCount ; Value: PatternCount ( $DateText ; "/" ) //only set up for / as a delimitter.]
                                    If [$DelimCount = 0 // Only a day was entered]
                                       Set Field [ Table::Date ; Date ( Month ( Get ( CurrentDate ) ) ; $DateText ; Year ( Get ( CurrentDate ) ) ]
                                    End If

                                    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.

                                    1 2 Previous Next