Ultimate Find / List Versus Form
Subtitles of the Movie
Right now, our Find script returns us back to the original layout. You may like this, but a lot of people want to show a Form View or a standard results view and, depending on whether they have one record or multiple records showing, either a Form View or a List View. So let's show you how to do that. We're going to go into ScriptMaker, come down here to our Ultimate Find and we'll edit this. It's a little bit more complicated than we might think. The easy part is we'd need to add in Elseif, so we'll move that in there. We'll say Get FoundCount equals 1, so in other words, if we've found just one record, then we're going to say Perform Script and we're going to come find our Form View script. Now, if you don't remember the script, let's go ahead and save this right now, go in and find the Form View script. There we go. It uses the same basic concept we've been using all along, Get Layout Name, Left Words, add on the word Form. So we're going to be on a Find layout, so just go back to our Find layout or go back to Customers without the Find but Form onto the end, or go back to Invoices, but add Form onto the end from our Invoices Find layout. So it's a really simple little technique I use all over the place to make things dynamic. So we'll come back in here, edit it, and now, otherwise, we must well, we need to also put this right here. We'll take off that little message here. We don't really need that anymore. There we go. We'll take this message off and so if, obviously, it's not one record, we must have found multiple records, so we'll say Perform Script, List View. There we go. It's very simple, very similar to this one, very easy script. So now we're ready to go, almost. We don't really want it to do Go To Layout, Original Layout, because then it will go to Form View or List View and then go back to Original Layout and that's no good. We actually want to move this up, though, in some situations we want it to run. Like, here we want it to run. We want it to go back to original layout because we entered no Find criteria. Then we also want it to do essentially here, but this won't quite work here because we're going to show that custom dialog, Show All Records, and then go back to the original layout, but this is going to happen each time we get in here. Remember, this one automatically exits at this point, so that's okay, but we don't want to go back to the original layout if they choose to redefine their find criteria. So what we need now is an IF statement, so we'll put one in there and we'll put this stuff inside there, put the Show All Records there. We'll say If Get Last Message Choice equals 2, essentially what we had in the Exit loop, so we don't need to test that again, so I'm going to change this just to a 1. So now, since we have two things we have to do when we exit the loop, because we only want this to happen once when we decide to exit the loop, not if we actually want to redefine Find criteria, now we have to have this portion inside an IF statement so we can run two steps and then we don't really need to test it here anymore because if this is true, well, then we need to exit the loop, no matter what. So we're ready to go. Let's save this. Let's come in here and try it out. What we're going to do is hit the Find and we'll find something that we know will find multiple records and we go to List View. Great. Let's hit Find again. We'll type in something we know we'll only find one record. There we go and we go to Form View, so that works great. Everything is perfect. Let's also test out, though, what if we enter something it can't find? Hit Continue. That message is there because Set Error Capture is off right now. We'll hit No this time and you can see it comes right back here just fine. Now, if we do this Find and type in Johnny again, hit Continue, Continue again, hit Yes. You can see it's on the correct layout. We can modify our Find and there we go. So it's extremely important when you modify scripts, especially complicated ones, like the one we have, that you try to test all scenarios. Make sure you test it inside and out because you may make a change that you think has no effect somewhere else, but often it does, so it's a smart idea to become a good tester because your solutions will come out much better. If you know how to test them properly and test them constantly, each time you change them, then your product will come out much better.
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
- 81,350 Video Tutorials (20,800 free)
- Video Available as Flash or QuickTime
- Over 782 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 