Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to check a checkbox

Status
Not open for further replies.

ckier

Technical User
Jan 1, 2008
3
US
How would I script filemaker to check a given checkbox?
 
ckier,

In Filemaker, a checkbox is is really just a regular field formatted to show a checkmark next to selected values. So for instance, if your field contains the values "Yes" and "No", to script the checking of the box what you need to do is enter the value of either "Yes" or "No" into that field. That is typically done using SET FIELD:

Set Field [TableName::FieldName; "Yes"]

This will checkmark the "Yes" value. To remove all checkmarks you simply clear the value from the field:

Set Field [TableName::FieldName; ""]

You should be aware that if you entered the text "Maybe" into the field, neither YES or NO would be checked nor would you be able to see the value MAYBE. The value list that you have assigned to that field must contain all valid values that you want to display. In this case you would need to have YES, NO, and MAYBE as values.

-Striker
 
thanks so much for your help. The script worked perfectly. My only problem is that this step is part of another script that finds a bunch of records and then checks off the checkbox on all of them and my script only checks off the first record. I tried the select all command before set field command but that didn't do anything. How can I incorporate a select all records command.
 
To change more than one record you would use the REPLACE FIELD CONTENTS command. This will replace (or set) the content of your field across all records of THE ENTIRE FOUND SET so PLEASE USE WITH CAUTION. If you make a mistake you will be changing all records in the found set which could possibly be every record in your database!

What you want to do is specify the proper Target Field and then choose "Replace with calculated result." The calculation is simply the literal text string "Yes" or whatever you want to checkoff.

Again, always use this command with extreme caution as it can do mucho damage in a heartbeat and there is no undo. Whenever I script this command I like to test for proper conditions (like a reasonable found count) and not proceed unless all is well. I also like to include a warning message to the user (Custom Dialog) and have them confirm that they actually do want to proceed.

-Striker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top