Scripting & Calculations / Birthdays pt. 2
Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.
Learn More
Subtitles of the Movie
Now we showed you in the earlier tutorials, if you had FileMaker 8 or later, you could use the asterisk to locate this, but you really don't want to have to teach that to the people using your system. If this is something you do every month to find all the people, let's say customers who have a birthday this month, you want a little button that will do that for you. So we're going to show two ways to do it. We're going to show a version for FileMaker 7, and a version for FileMaker 8 or later. So, for FileMaker 7, you need to do this, go into Define Database, and it's not that difficult, but you need to create an extra calculation called month. That will be calculation, we'll create that, and it will simply be month open paren and we want to go to the DOB field, double click on it, close paren. That will extract the month, and we want a result of number, so instead of showing the day and the year, you'll just see a month number. So, somebody was born in 1967 and somebody who was born in 2001, they're going to have the same value if they were born in the same month. So we'll click Ok, go into ScriptMaker, and we'll make ourselves a new script. We'll call it Find Birthday, or B-Day sounds good, v7. And we're going to need to start by entering Find mode, which is pretty clear how to do that, enter Find mode. We do not want to pause, so I'm going to uncheck that, we want to actually enter Find mode, and then have it immediately go to the next step, otherwise pause requires the user to interact and click the pause button, we don't want that. And then what we're going to use is a step we haven't used yet, but it's my favorite one if you remember. We're going to move in Set Field. Now Set Field essentially allows you to take the result of a calculation, and put it into a field. So after we enter Find mode, we want to make our criteria with Set Field. So our target in this case is going to be the month field, we'll click on that and click Ok, that's our target. The result, down here, is going to go into that target field. And that's going to simply be month get current date close paren close paren. So look at the current date, get the month out of there, and put that in the find criteria, simple as that. And then, we don't want the person to have to click the Find button over here, we need to actually make it happen for them, so we're going to use Perform Find. Now make sure you don't confuse this with Perform Find/Replace this is entirely different. We want to go down to the one that says Perform Find, which is down in the Found Set section, it's right at the top and just says Perform Find. No options on this one, we're set to go. Enter Find mode, put in the find criteria, perform the find. Close this, we'll leave it under the Scripts menu, and let's run it and see what happens. And it looks like we found one birthday here. The month happens to be May. And if you're unsure if this worked or not, well let's go to another record, show records, let's go to a different record and make it a May birthday, there we go I'll make that 5/21. Run the script again, and you see we find both those records. So, it looks like it's working, whatever the current month is it will find all those birthdays, which is great. Well let's show you a little bit easier way to do it, well it's not really much easier, it's just that you don't have to add a field. So if you have FileMaker 8 or later, you're going to be benefited by the fact that you can use those asterisks in the find criteria. Now we don't want people to have to remember that, so we're going to completely script it. So we'll duplicate this script, and we'll come in there and edit it, and we'll change this to v8, and I'll put a plus sign here, because it could be v9 or any version that probably comes out in the future. And what we're going to change is the target, we don't need the month field for this version, so if you're on v8 you don't even have to make the month field, and we'll specify the dob field. And what we're going to specify is still the same thing, get that month from the current date, but everything else will be a wild card. So quote slash asterisk slash asterisk quote. Get the current month, concatenate that with a slash, an asterisk, a slash, an asterisk. In other words, only the month is the value in there, everything else, the day and the year are wildcard, could be anything. And that's it, that's all you have to do. So now it's completely a script driven function; there's no fields involved other than the ones you already have. So close that, hit save, close this, we'll run the v8 version, and the found set should stay the same. And if you wan to see what it put in, just to really check to make sure, we can go up to records and choose modify last find. And you can see it put five, slash asterisk slash asterisk. The next month it will put a six here instead.
Tutorial Information
| Course: | FileMaker Pro 9: Beginner |
| Author: | John Mark Osborne |
| SKU: | 33783 |
| ISBN: | 1-933736-95-X |
| Release Date: | 2007-07-26 |
| Duration: | 12.5 hrs / 145 lessons |
| Work Files: |
Yes |
| Captions: | Available on CD and Online University |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 98,729 Video Tutorials (23,265 free)
- Video Available as Flash or QuickTime
- Over 1026 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 