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.
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.
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?
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...
You are using a database, so you're creating new records. Wouldn't "Auto enter creation date" solve this?
Or, instead of a script use "Get ( CurrentDate )"?
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...)
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?
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.
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?
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).
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.
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!
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 ) ) ]
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.