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
Let's create a script to locate upcoming birthdays. As we learned, we can't really search this field because it's not indexable, so if we want to locate people who have upcoming birthdays, we really need to search our date of birth field. We learned how to do this manually, but you really shouldn't expect your users to remember how to do this. They may only do it once a month and they'll ask you every single time. Your job is to make the program easy for the people to use it, so program it for them. Make it a single button that says Locate Birthdays. Now, we have a FileMaker 7 and a FileMaker 8 and later versions because the feature that we're talking about, the asterisks that you can put into a date search or into, you can put the month number you want to search for and then asterisk for the day and asterisk for the year, well, that's not available in FileMaker 7. We're going to show you both versions, but actually, in some ways the FileMaker 7 version is better. We'll compare and contrast them. So, for the FileMaker 7 version, let's go into Manage Database. We'll make a new field called Month. That will be a calculation field. We'll create it and all we have to do is say Month and that will allow you to extract the month from a date field, so we're going to go find our DOB, close paren. We do want a number result, and that's it. We want just the month. That's so we can search, regardless of the day and the year. We want to know what month they were born because we want to locate anybody who has a birthday in the current month. You know, if you're in February, if today is in the month of February, we should locate all February birthdays, regardless of day or year. So it's as simple as that. We'll go into ScriptMaker, make a new script. We'll call it Find Bday V7 and we need Enter Find Mode. That will be our first step. We'll move that over, but we don't want it to pause because we're going to enter in the Find criteria ourselves. If it pauses, then that usually is for users to come in and say, hey, this is what I want you to do and then I'll continue it for you. We want it to go real quick and just do the search. The next step we're going to use is Set Field. As you remember, this is my favorite script step. It's a very important script step and we'll go over it real briefly here and we'll use it quite a few more times if you don't quite get it, but the basic idea is you specify a target. That will be a field and we'll specify our Month field, that one we created, and then you specify a calculated result, so what we're going to do is we're actually going to be putting together, in this particular set field, find criteria to search in that month. It's very simple. We just say Month, open paren, Get Current Date, close paren, close paren. Search or get the current date. Let's say it's February 2 or February 5 or whenever you decide to do this. Grab that 2, that month, and put it into the Month calculation field, but in Find mode. Very simple formula. Then we want it to automatically search. Now, don't use Perform Find Replace. This is not the right command. This does something entirely different. It does a word processing type Find and Replace inside of Browse Mode. You actually want to initiate the Find. We've gone to Find mode, put the Find criteria. We actually want to perform that Find. You'll find it down here in the Found Set section, so that's the one you want right there. So we'll close this, save it, and let's give it a little try. We'll see if we have any birthdays in this month. There we go. You can see it's October and we found two. There's both October dates. So, regardless of the day or the year, you can see it's searched and found those people and then you can at that point send an email to them, call them up on the phone, print out a letter. We'll get into that kind of stuff later, but you can add, certainly, onto the script and do lots of things with it. So let's take a look at the FileMaker 8 version. It does not require an additional field and that's one of the advantages, so we'll go into ScriptMaker. We'll duplicate this. We'll edit it. We'll call it V8 Plus, because this will work on any version but you have to have at least Version 8. We're still going to enter Find mode and still perform the Find, but we don't need this Month field, so we're not going to put our Find criteria in there. We're going to put it into DOB. We'll specify we're still going to use this, but we're going to concatenate, quote /asterisk slash asterisk quote, so you can see that we're just putting into the DOB field a standard date based on the current date, so if it's February, we're going to get 2 /asterisk /asterisk. In other words, asterisks will ignore the day and the year, so this will work great because we don't have to have a field, but, as you notice, what we're not going to get is the ability to send it overseas because the month is going to actually be in this spot in the United Kingdom or Australia, so this is one of the down sides of this approach. You don't need the additional field, but it's not going to work in another country that doesn't support the same format for dates. So I've thrown both of them out at you so you can really decide which one works best for you. So we'll close this, save it, close it. I'll Show All Records, just to make sure, but remember we found two before, and then run that script and you see we find the same two records. We can actually go in and modify the last find and see what it entered. 10 /asterisk /asterisk. That's because it's October right now. So, go into Browse Mode. That's your script for finding upcoming birthdays and, if you want, you can take this further and decide I want to find birthdays that are upcoming in the next two weeks. It gets more complicated. Obviously this is much easier, but you could write them. We will go over more complicated scripts that do different kinds of date ranges and that will help you if you want your birthday search to do something other than just the current month.
Tutorial Information
| Course: | FileMaker Pro 10: Beginner |
| Author: | John Mark Osborne |
| SKU: | 33925 |
| ISBN: | 1-935320-18-1 |
| Release Date: | 2009-01-05 |
| Duration: | 15 hrs / 172 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 