1 Reply Latest reply on Jun 15, 2012 3:46 PM by philmodjunk

    Variable buttons

    GlennPetersen

      Title

      Variable buttons

      Post

      Hi,

      I have a quotation db, where we can make categories for sorting the quotations, ex. into rooms.

      Now I would like to make a script makeing Variable buttons, with the names of the categories used in the specifc quotation. The buttons are usiong the portal table, and there should also be a standard button with the name "Show All".

      Who have a good idear for this solution?

      Rgs Glenn P

        • 1. Re: Variable buttons
          philmodjunk

          Note: a drop down list or pop up menu is more flexible for this as you don't have to edit your layout to add more buttons if you later need to add more categories.

          The following requires FileMaker 11 or later--there's an alternative approach that can work with earlier versions:

          For this example, Let's say, your categories are "Living", "Kitchen" and "bedroom".

          Define a table: Categories and create one record with three records--one for each category, with the category name entered in a text field--CategoryName.

          Relate Categories to your current table with the X operator instead of =. You can select any fields you want for match fields with this type of relationship.

          Put a one row portal on your layout with an initial row one and the CategoryName field in the portal row. Put two more identical 1 row portals on your layout, but specify initial rows as 2 and 3 respectively. Now, In browse mode, you'll see all three category names displayed on your layout. You can arrange size and format these portals so that there are no visible borders and you can place them on top of a graphic for the button or an unlabeled button object.

          Note that you can change the categories by editing data on the Categories layout and you don't have to alter scripts and or your layout (except to add or remove more buttons should you need more or fewer categories).

          While in layout mode, select the CategoryName field and use button set up to turn it into a button that performs your script.

          You don't indicate exactly what you want your button to do "sort" and "show all" are two different functions. I would assume that you want to find records. a possible script for these three buttons might be:

          Set Variable [$Category ; categories::categoryName ]
          Enter Find mode []
          Set field [Yourtable::Category ; $category ]
          Set Error capture [on]
          Perform find []

          This script assumes a lot about your database. It will not work without modification if the records to be searched aren't in the current layout's table.

          To add a "show all" button, you can use the button tool to add a button to your layout and specify either the Show All Records option or it can perform a script that uses Show All Records. (With the script, you can also sort the records in a specified order.)

          Note that this same method works with a single, multiple row portal where you could then click any row in the portal to select that category.