|
|
|
Navigate: | My Mac Online | The Archives | May 2000 | FileMaker 101 - Part 26 | |
![]() |
|
![]() Part 26
My Mac Magazine manavesh@mymac.com
Multi-keys with Portals ["How to use the different lines in a multi-key to filter a portal in a variety of ways."]
Portal vs. List
Portal One advantage of using a portal instead of a list is that the portal, by definition, is already a related group of records. This means that we don't have to issue a "Go to Related Records" command to get the records to change after changing the key (which we did with the window list). All we have to do is change the key, then exit the record, and the records will change to match the new key. In order to be able to change the key to anything we choose, without affecting the records, it should be a Global field (Portal g). It should be defined as related to an indexed key in the file we want to see in the portal (in the same file or another file).
Exit Record/Request Step (again) If it is needed in a script, you can often tell because the script may work sometimes, but very inconsistently, often going to records related to the last value that the global was set at instead. It's about the only time that happens.
Portal Refresh
Multi-line Target Field for Relationship
In this case the field, in the Storess file, will be a calculation field, result Text (important). Portal ID c = What?! The first line is kind of what you'd expect, except that People IDs is already a multi-line field of its own. But that doesn't really matter, you can have lots of lines. It holds all the people that have shopped at that store. That is the power of multi-key fields. You can match any line. The second line calculates the first letter of the store's name, Left (Store, 1) The last line is just a "1," a constant value for all records.
As you can see, there is no real "overlap" between the lines. A text value is not going to match any of the ID's in People IDs or 1.
3 Ways to Change the Global Key The Person's ID will match any stores that have that ID in any of the lines of the Portal ID c field, and these will show in the portal. This is the default view. If you want to enter a store that wasn't visible, that they had not shopped at before, then there is an easy way to look for it. Click the box with the little letter in it, the Last g field. This triggers a script that enters the field, pauses for your input, then sets your choice into the Portal g field, then exits. Portal g will now contain a single letter, which will match the Left (Store, 1) line of Portal ID c. All stores beginning with that letter will show in the portal. The "All" button sets a "1" into the field. This will match the "1" in Portal ID c, which is the same in all records, so all the stores will show.
It only happens when you show two fields in the value list, when you are using the "Also show values from a field," showing a 2nd field on the right. It also only happens when the 2nd field is indexed. It usually is, as it allows that field to determine the sorting order.
If there are two entries which are not unique in the 2nd field shown, only one of them (the first) will show in the list. For example, you have two people with the same name. Each has its own record, with a unique ID, 001 - John Smith and 002 - John Smith. That's as it should be. You have further concatenated them in order to get a sorted field (LastFirst) for a value list, = Last & ", " & 1st.
This gives you Smith, John for both, still not a problem, since the ID will keep them separate if you use the field on forms and lists, and the ID would be used for relationships. But when you format that ID field as a pop-up value list, using itself as the 1st field and the LastFirst field as the 2nd, you only get one choice: The 002 John Smith is simply left out, since value lists always drop any duplicates in the indexed field that is used for sorting. And, since the ID is not much of a clue, you could easily end up with the wrong data. There are a few cures. The first is to create a mirror of the 2nd field, an unstored calculation field, = Last & ", " & First. But then it couldn't be used for sorting, which defeats half the purpose of using it.
A better fix is to tag a unique value onto the end of the 2nd field. You could add the ID field again, = Last & ", " & First & " " & ID.
This is one reason I seldom use the built-in value list. The above problem, as well as those of filtering and layout make it easier to use my list and portal methods outlined above.
Fenton Jones
Websites mentioned:
FileMaker 101 - Previous Columns
|
|
Copyright ©1995-2000 My Mac Productions, All Rights Reserved |