Home
Username:
Password:
FileMaker Pro 10: Advanced Tutorials

Ultimate Find / No Find Criteria pt. 1

Subtitles of the Movie

When you turn on Set Error Capture, you have a great responsibility to know all the possible errors that could occur. Otherwise, you could have disastrous results. Let's say you didn't know an error could occur in a script that deletes all records. It's possible, by not identifying that error, it could show all records and then delete all of them, rather than the handful of records you had planned to actually delete. While it's not quite that disastrous in our Find script, an error can occur that we hadn't planned for, so let's demonstrate it manually. If we go to the View menu and choose Find mode and then don't enter any Find criteria and simply hit the Enter key to perform the find, it gives you the No Find Criteria error message. So, let's run our script with that, but before we do, let's go ahead and go into Manage Scripts and go into Set Error Capture and, briefly, we're going to turn error capture on so I don't have to log back in as a basic user to test this. So we'll save this and what we're going to do is we're going to run that script, put nothing in there, and watch what happens. No error message occurs. That's because we haven't tested for it. In fact, what I want you to see is what happens when we go ahead and turn that back off. So let's save that. We'll do that Find again, No Find Criteria, and this time you get the error message because Set Error Capture is off. If we click Continue, you normally would have gotten your message there if we had tested properly. In fact, why don't we go ahead and try this. We'll type in Johnny, hit Continue. We get no records to match this. If we hit Continue, we still get our message, so you actually don't have to have Set Error Capture on to see your error checking, as long as you realize that there's going to be a FileMaker error and there's going to be your error message. So we're going to keep it off for right now. I just wanted you to realize that. Let's go ahead and see if we can fix this script. So we go into ScriptMaker, find our Ultimate Find and we'll edit it. We've already shown how to figure out what an error is. You can use your script debugger or you can show a custom dialog. We're not going to show that again; we're just going to tell you what the error is. So we're going to put an Elseif in here, go and modify that and we'll put in Get Last Error equals 400. So a 400 error is no find criteria. Then we'll put in a Show Custom Dialog. We'll move down here. We'll say No Find Criteria. No Find Criteria Was Entered. You Will Be Navigated Back to Data Entry Mode. Looks good. A little misspelling there. There we go. Take out the Cancel because we're going to give them no choice at this point. Click OK. Now, we don't have to do a Show All Records here because what happens if you enter no Find criteria is it actually takes you back to Browse Mode with the same found set you had before you went in there. So we don't need to do that here. Here we had to do it because we had 0 records at that point. Now, in FileMaker 10 and FileMaker 10 only, this will actually work. Let's explain what happens in previous versions, FileMaker 9, 8.5, 8, 7, and so on. If you have this set-up right here in FileMaker 9 or earlier, what's going to happen is the error's going to get lost, so let's explain that. If we go up here, where we turned Set Error Capture on, we're going to walk through these script steps and when we run this script step, we're going to get an error of 0. It's possible to get some type of error, but unlikely. If we go to this layout, unless it's not there, it's going to give us an error of 0. If we enter Find mode, that will probably be possible, so we'll get an error of 0. Only here do we anticipate getting errors, either a 401, a 400, or a 0. So let's say we get an error 400. The first thing it does is it goes right to this and it substitutes that error into this Get Last Error. So it says does 400 equal 401? That's false, so it skips down here and what it substitutes in here is a 0, not a 400, as you might expect. Well, in FileMaker 10, it does put a 400 in there, but in earlier versions, it doesn't. That's because when we ran this script step, it gave an error of 0. Every script step gives an error, whether it's a 0, which is no error, or some kind of error, so in other words, errors are stored in memory for one script step, so if an error occurs here, you can test it here only, but in FileMaker 10, they changed that. They decided that If statements didn't have to create that way, so inside an IF statement, especially with an If Elseif, you can test all the way down here for that error, but I want to show you the different work-arounds for your situations, in case you don't have FileMaker 10. So what we'll do is one solution will be Set Variable. We'll come in here and put a Set Variable in there. We'll put dollar sign Error and then Get Last Error. Click OK on that and what we're doing is we're taking a snapshot. Right after where the error occurs, take a snapshot of it. That way, we can come down here and we can say dollar sign Error, and the same here, dollar sign Error. There we go. So it's as easy as that. This is the most common way to keep that error in memory if you don't have FileMaker 10. Even in FileMaker 10, sometimes you may need to test for the error way down and you'd still need to do this.

Tutorial Information

Course: FileMaker Pro 10: Advanced
Author: John Mark Osborne
SKU: 33927
ISBN: 1-935320-20-3
Release Date: 2009-01-05
Duration: 12 hrs / 150 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