Ultimate Find / Save by Table Occurrence pt. 1
Subtitles of the Movie
One thing I don't like about the FindScript is the Show Records script step. When no records are found, you need some way to show records, and we've chosen Show All Records at this point, but what I'd rather have happen is the person goes through their Find, they're typing in find criteria, and they keep modifying the last find, but they never come up with anything that finds records, and they finally hit No to go back to Data Entry mode. What I'd like to have happen is to restore their Found Set rather than just showing All Records, because found sets are the foundation of a database, so it would be nice to bring them back to that, and then they can say, Oh, let's continue on working with this. So, that's what we're going to try to do, and we've actually already discovered how to do it. If you remember, on our Invoices Layout, we had a different table occurrence and that resulted in different found sets between these three layouts; or actually this List view is four layouts. So, different table occurrences stored different found sets. Well, we can really use that to our advantage. So, what we did was, we went into Manager, Define Database, into Relationships, and we made these three table occurrences: Customer Save TO, which is based on customers, and then we also had Invoices TO, or Save TO, which is based on Invoices, and then Products Save TO. We also went in and made layouts based on them. So there's Customer Save, Invoices Save, and Product Save. There's nothing really special about the layout. It's just the layout setup. So each one of those layouts is based on those new table occurrences, therefore, they're different than these ones right here. That means that we can store a Found set in that table occurrence essentially on that layout, and here's how you do it. We go into ScriptMaker, and we'll look at Save TO Test, and all we do is Go To Relayed Record. Our starting point is Customers and our ending point is Customers; very strange. The starting and ending point, because the layout we run this on will be Customers, or attached to the Customers table occurrence and we'll be going to the same table occurrence. The difference is we're going to say, Show on a layout called customer save, and show a only related records. This is the key. It's going to transfer this found set to this layout, or to this table occurrence essentially. So let's run it and see what happens. Okay. So, let's make a Found set here. I'll omit some records; just do it with the keyboard command. Here we go. We've got 35 records found. Let's go ahead and run that Save TO, and you can see now we have 35 records found here, as well. And if we come back to Customer's Form, and Show All Records, and go back to Customer Save, we still have 35 records found. Until we actually change it here, it's not going to go away. We have to change it on some layout that's attached to this table occurrence. So, if we go into Layout mode and go to Layout setup, we'll see it's attached to Customer Save TO, which is different than the other ones, which are customers. So, now that we've got it saved, we can restore it with another script. It's exactly the same thing, just the opposite direction. So what we say is, Go to Related Record from Customer Saved TO, and this relies on us being on this layout as well, so it's the same thing, instead of customers to customers it's customers saved TO to customers saved TO, and then show the record using Customer's form which is from an entirely different table occurrence. Same exact, same thing. So, what we're going to do is save this, come in here, make sure we're on Customers Save, we're going to run that script, Restore TO, and you can see how now we're on Customers with the same Found set. So, it transfers it for us. And this is a really cool technique. It's similar to our Save or Found Set technique, but much faster, but it will also find out what the Save a Found Set technique that we can make it so it's permanent. This is temporary as well; saving it in a table occurrence. It doesn't store more than one Found set for us, but that's perfect for our Find script, because we only need it to store temporarily. So, let's go into ScriptMaker, and let's take a look at the version that has been created for the Ultimate Find. So, we have three tables, so we go to Customers, Invoices and Products, check to see which layout we're starting on. So, if we're starting on Customers we do this Go to Relayed Record. Go to Related Record from Customers makes it really exactly what we showed you before, and the same thing here; we'll be on Invoices so go Invoices to Invoices, and then show an Invoices Saved, and really the same thing with Products; no difference. And then we say, Go back to original layout, because we really don't want to show that layout at that point; we want to go and save it onto those layouts and then come back to where we started from. And then we, of course, have the restore TO, and in order to limit what we did, we had one Go to layout, we knew we'd be starting on a layout that had the name either Customers or Invoices or Products, so all we had to do was our technique where we get the layout table name and then add underscore Save onto it. So as long as our layouts are named properly, this will go to the right layout and then we'll say, Hey, where are we? Are we on Customers, are we on Invoices, or are we on Products? Well, depending on that, then we go the other direction. We say, Go from Customer Save TO to Customer Save TO and the one difference here is we say, Go back to dollar sign dollar sign last layout. We stored that and that gets them back to the original layout. So no matter what they started fromÑlist view, form viewÑit'll get them back to the right layout and that's pretty cool. So it's really the same thing here as well. Invoices saved to Invoices saved; layout number by calculation, dollar sign dollar sign last layout, and just make sure, same thing here: dollar sign dollar sign last layout. So that's it for that script and now we need to find out where do we put these inside the Ultimate Find. Well, the saved TO goes somewhere before we change layouts, so right here is good, or we could have put it up here at the beginning just before this Go to Layout, and then here's where we need the Restore TO; we've replaced the Show All Records with the Restore TO because we only really want to run it when they click No. That's when we want to restore that Found set. And so it works perfectly. So we'll see how it works, in fact we'll go over to a different layout. Let's make a Found set. We've got six records. Let's omit a record; now we're down to five. And let's run the Find. Type in something it couldn't possibly find, hit Continue, hit No, and we're back to five records, so this works perfectly.
Tutorial Information
| Course: | FileMaker Pro 9: Advanced |
| Author: | John Mark Osborne |
| SKU: | 33824 |
| ISBN: | 1-934743-32-1 |
| Release Date: | 2007-11-21 |
| Duration: | 10 hrs / 115 lessons |
| Work Files: |
Yes |
| Captions: | For Online University members only |
| 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 