Making FileMaker Buttons Perform Diverse Functions

From Dwayne Wright PMP
Certified FileMaker Developer

WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts

Please Note: If you are viewing this page in a news feeder, the images may get munged up a bit. For the best experience, please visit the journal directly by clicking (here). 

You may have a button on your FileMaker screen that performs a hidden operation, such as delete this record, go to an otherwise hidden place or perform a script. For example, you could make the “New Record” button delete the current record if the user holds down the shift key. This is done by using a script that branches based upon what it sees via the Get ( ActiveModifierKeys ) function.

If [ Get ( ActiveModifierKeys ) = 1]
Delete Record
Else
Create New Record
End If

The Get ( ActiveModifierKeys ) function itself will return a number result depending on which combination of a particular family of keyboard keys that are held down at the moment. If more than one key is held down, the function results the sum value of each key. The individual values for each key is Shift = 1, Caps Lock = 2, Ctrl (Windows) and Control (Mac OS) = 4, Alt (Windows) and Option (Mac OS) = 8 and Command (Mac OS) = 16. If a user was holding down the shift and the Ctrl keys, the function would return 5. This is the sum of the two key ( Shift = 1 ) + ( Ctrl = 4).

Here is another example that I used this last weekend. Last year, I scanned all the photo from all my photo albums in a effort to get them all online. My scanner allows me to put multiple images on the scanner bed and then creates a file for each indivual picture. Trouble is the files have names such as sc000a0b32.jpg, so I started building a FileMaker Asset Management system. I piled all these scans, scans from years ago, pictures sent to me and digital photos taken.

I then looked at the photos in list view and need to add the metadata I want to them manually. One thing I do is selectively omit records from a found set before I use the replace command to add my metadata to the records in a batch. I had isolated 600 pictures that had myself as the primary person in the picture. I only wanted a found set of those before I went into junior high. So here is the script that I attached to a button that would allow me to omit one record or all the pictures I could see in a viewer (5) via the same button.

More info about the author and FileMaker in general, contact me at info@dwaynewright.com.

© 2010 - Dwayne Wright - dwaynewright.com