|
|
|
Navigate: | My Mac Online | The Archives | February 1999 | FileMaker 101 - Part 11 | |
![]() |
|
![]() Part 11
My Mac Magazine manavesh@mymac.com
Calculated keys & portals This month is going to be mostly catch-up, for me to go back and explain some things in the example files. There were a couple of layouts and operations that got left out. Maybe you've already figured them out.
Alphabet Layout with Calculated Key In the Phone.fp3 file there is a layout named Alphabet. There is a global field, Alpha g, on the left, formatted as radio buttons. It is also formatted to use the calculation field Alphac as its Value List. As soon as you have enough records, it will appear as the letters of the alphabet (you could type in the alphabet yourself, but why bother)..
Alpha c is defined as the simple formula, = Left (Last, 1)
There is a relationship between the two fields, Self Alpha; The portal is also based on the same relationship. So if you click one of the letters, a relationship will be established between that letter and first letter of the last name field (in the portal) instantly showing the related records. To go to that record, a transparent button over the names is attached to the script Go Main Alpha g:.
Set Field ["Serial ID g","Self Alpha ::Serial ID"] The global Serial ID g temporarily holds the value of the Serial ID field, which is an auto-entered text serial number; most files should have these two fields. The Self Serialg relationship between them will always be able to identify a record(s). You have to use these steps to get out of the portal, which is considered as if it's a separate file..
Clairvoyance Layout For relationships FileMaker considers each line of an entry in a field to be a separate record..
So, the only thing that is needed is to put paragraph returns between them. In this case we'll just expand on the earlier calculation field (text result) to create a new one;
A global text field, Last g, will hold user-entered letters to match up to this. Make a relationship between them, Match Last g; As you type letters into the Last g field, the records that match it will narrow down to the correct name(s). There is one problem: the portal records don't refresh unless you either hit the Enter key or click somewhere outside the fields. But then you're not in the Last g field anymore. To type another letter you have to click back into the field. Clunky.. There are two methods I know of to fix this. Both use scripts. The first begins a loop, pausing and resuming every second to refresh the portal. This works, but the screen refreshes are unnerving, and you still have to click to end the script. I came up with an alternative script, Clairvoyancer, which is a little smoother, but still requires the Enter key..
Loop It requires a button, Begin, to start it. You enter a letter with your left hand then hit the Enter key with your right. This feels fairly natural. It triggers the Pause/Resume step, the portal refreshes and the cursor is in the Last g field, ready for the second letter (in case just one wasn't enough). The loop continues..
Now we come to the fun part. Because of the paragraph returns, the two letters in Last g There is also a transparent button over the names in the portal, this time based on the Match Last g relationship, to set the Serial ID and go to that record.. The one caveat is that the loop is still continuing. It can be stopped by choosing the Exit Script option in the little drop-down menu that appears when you attach the following script to the transparent button:.
Set Field ["SerialIDg", "Match Last g::SerialID"] Just to be safe, in case there is no match and the user leaves the layout, every navigation button on the layout should also have this option chosen. You'd want to stop them using the Window Menu also; but that's a whole new kettle of fish..
Limiting Menus
Multiple Checkbox Choices in a Global Field Reviewing Duplicate Records Before Importing. I added a routine in the Import example file to allow you to review duplicate records in Transit before deleting them or using them to update the original entries in Import. The operations are fairly simple, but they hop back and forth a little..
Checking Related Records
Perform Script [Sub-scripts, "Copy All Records"] The new steps begin with If ["IsValid(Concat g::Last)"]. I love this step. In general terms, If [IsValid("the relationship::any field with data)"]. Its beauty is that it checks to see if there are related records before having to go to them. That is much better than using the Go to Related Record [Show, "Concat g"] by itself and then having to trap for Status(CurrentFoundCount)=0. You can use this step to check for related records first in either scripts or calculations.. The way it is used in this script if there are no related records the first If isn't fulfilled and nothing happens. If there are related records the message above is displayed. "Yes" is the default choice, which is trapped by If [Status(CurrentMessageChoice)=1]. A simple script with a single step, Halt Script, is then called as an external script in Transit to stop everything. It's in Transit so that its window is brought to the front and you can see the duplicate records..
Halt Script vs. Exit Script
Review Button in Transit
If ["IsValid(Import concat::Concat)"] The first step checks if there is a related (duplicate) record. If so it displays it in form view in both files, so you can see all the information and make a decision. I sized the layouts and windows so they can be tiled horizontally and still see everything.. Finally, there is also a button to delete the record in Transit. There is no need to delete the one in Import, as it will be overwritten by the Relookup script.. You'll have to run Relookup again manually after reviewing, since I halted it. Another way to do it might be to use a different combination of Exit script steps between the files, so the script would only be paused. But this way seemed good enough, and less prone to user (and creator) error..
Fenton Jones
Websites mentioned:
FileMaker 101 - Previous Columns
|
|
Copyright ©1995-2000 My Mac Productions, All Rights Reserved |