Scripting & Calculations / Birthdays Find
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 said before, we can't search the Age Field even if it had enough information to locate for an upcoming birthday because it's unstored and anything that would be a Calculation that determines whether somebody's birthday was up or not would have to be unstored to keep up with the Get Current Date. So we're going to have to do something different. We're going to have to search in our Date of Birth Field and there's actually two versions of this Calculation that we're going to do. One requires a Calculation Field for FileMaker 7 and one requires a Calculation just in ScriptMaker. So let's show you both. There are advantages and disadvantages with both. So we'll start with the FileMaker 7 version. We'll go into Manage Database and we'll make a field called Month. That'll be a Calculation Field, we'll create that and it'll have a number result because it's going to be month and we're going to go ahead and find the dob field, double-click on it and all it does is it extracts the month out of that date field so we can just search the month and not have to worry about the date or the year. It's that simple. Click OK. Click OK again and now we write the Script. So, it's a two-part feature. We have to have a Calculation and a Script. So we'll go and say find birthdays v7. Now again, this can be used in version 7, 8, 8.5, 9, or 10, or 11, or any version will work fine. The version we're going to show you next can only be used in 8, 8.5, 9, 10 and 11 because it uses a new feature that came in in version 8. So the first thing we're going to do is enter Find Mode, move it over there. We don't want to pause it. The pause would stop the script so you could do something, but we want it to just run all the steps as fast as possible. And we're not going to have it remember any Find Requests because we're going to enter it in with the Set Field Script Step. Now if you remember, the Set Field Script Step is my favorite Script Step, so we're going to give you a basic overview here. The idea is it takes the result of a calculation and puts it into a target field. Now we're going to put it in the target field when we're in Find Mode, not in Browse Mode. We're going to specify our month field, that new field we made and we're going to say calculated result is month get current date close paren close paren. So, grab the month from the current date. So if we're in February it's going to put a 2 into that month field and search for all birthdays that are in this current month. Now, in order for this to actually perform the Find, because it won't do anything, this is going to enter Find Mode and put the criteria in, we actually have to say perform the find. So we'll type in p-e-r and you'll notice the first thing it finds is Perform Find Replace. This is not what you want. This is like your Find and Replace feature in a word processor. I hardly ever use it because it's very dangerous. You want the next Perform Find, which is just Perform Find, not/Replace. That says, when you're in Find Mode perform that Find. So this is all we need. We'll go ahead and save that. Close it. And let's see if we have any birthdays in this month. So we'll go up to Scripts and choose Find Birthdays and you'll see we found 2. Here's February 7th 1974 and 22nd 1943, so you see it's disregarded the day and the year. Let's go ahead and create the Find Birthdays v8, so we'll duplicate this, we'll go ahead and edit it and call it v8 and now what we're going to do is we're going to change this, the Set Field. The Enter Find Mode and Perform Find will stay the same, but we don't need to search in that month field. We're going to search in the dob field, so here's one of the advantages. It doesn't have an extra field to clutter up your managed database. But the formula's going to be a little bit more complicated. What we're going to do is say get the month from the current date and concatenate it with quote/asterisk/asterisk. So, if you remember, that's our wildcard. We'll search for the current month but we don't care what day and what year we have. We're just putting it into a Script so it's a 1-button click. You don't want your users to have to remember how to type this in. They'll be asking you every time they want to do it. Make it a button so they don't have to think. So we'll close that, save it and let's go ahead and perform that Script and we'll see it does exactly the same search and if we go and modify the last find we'll see what it put in there: 2/ asterisk/asterisk. Now let's take a quick look at what the disadvantage is. The advantage was it didn't have to use extra fields, but the disadvantage is it's not going to work in other, well, overseas countries. Let's say a country that started with day month year. Here in the United States we use month/day/year. Well, in other countries you might start off with the day and then the month and this is going to make it fail. And we can't really use the date function, which would solve that problem, because these asterisks won't work inside there. So, you've got to decide what version's better for you. Do you want an extra field that'll work and that'll work in any environment, you know, whether you're in the United Kingdom or Australia, or the United States, or do you want a version that doesn't require an extra field? It's up to you. I give you both of these choices. You decide which one you want.
Tutorial Information
| Course: | FileMaker Pro 11: Beginner |
| Author: | John Mark Osborne |
| SKU: | 34100 |
| ISBN: | 1-936334-10-0 |
| Release Date: | 2010-03-12 |
| Duration: | 14.5 hrs / 164 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 