7 Replies Latest reply on Nov 2, 2010 3:04 PM by kingsley47

    Restricting records in a layout



      Restricting records in a layout


      I have a database that summarizes specification requirements for types of material. There are various specifications for one type of material (with a single record for each specification) so I have created multiple layouts, one for each material type. However, these layouts share a number of fields. Right now, If I put a material specification into any layout, I can actually view that specification from any other layout (although it ussually ends up looking pretty weird). What I need to know, is a way to put in each specification so that it only shows in the correct layout for the material type that it is. I have added a drop down list to each layout that contains material types. That way I can use that to lable that record as a aparticular type of material. I'm pretty sure this is the correct first step but I have no idea where to go from here. Could someone please help me out?

        • 1. Re: Restricting records in a layout

          One way or another, you will need to synchronize the record with the layout type.

          You can use a variety of scripts with buttons and/or triggers for this.

          One way, is to set the same On RecordLoad trigger for all your materials layouts. Your script might look like this:

          If [YourTable::MaterialType = "Type1"]
             Go To Layout ["Type 1" (Materials) ]
          Else If [YourTable::MaterialType = "Type2"]
             Go To Layout ["Type 2" (Materials) ]

          //and so forth

          Everytime you change records, the script will fire and select the appropriate layout.

          If your Material Types and layout names exactly match, you can even do it with a single script step:

          Go To Layout [YourTable::MaterialType]  // use the layout name by calculation option.

          • 2. Re: Restricting records in a layout

            Ok, I had done something just like the first suggestion earlier in the week and was thinking there was a different better way to do it. Which, as it turns out, there is. Thanks alot Phil.

            • 3. Re: Restricting records in a layout

              Actually, this didn't work quite like I expected. So if I choose the material type from the drop down list it will change the layout to the correct layout for that material type. However, if I change the layout via the layout drop down screen, the record for the specification will still stay up no matter what layout I am in. I want to make it so that once I have chosen the material type from the material type drop down list, if i change the layout the normal way, I won't be able to see any records that don't have a matching material type. Right now, my material drop down list is almost like a duplicate layout drop down list.

              • 4. Re: Restricting records in a layout

                Did you try setting up this script with the On RecordLoad Scripttrigger?

                That way, any time your current record changes, the layout changes to match the specified material type for that record.

                This assumes a form view layout.

                If you are using a list or table view, this only works if all your records in the found set are of the same material type.

                • 5. Re: Restricting records in a layout

                  I am using a form view layout. The ON RecordLoad trigger worked. However, it had an unanticipated side effect. I am now unable to change the layout using the drop down layout list (when I am on a current record). Is there a way that I can still use the layout drop down list to switch to a different layout (that still only has records for the appropriate material) so that I can flip through records that way if I wanted to?

                  • 6. Re: Restricting records in a layout

                    How does your drop down switch layouts? With a script trigger?

                    If the current layout is correct for your current record, changing layouts pops you back to the current layout as that is the specified layout for your current record. You should first find a record or records of the desired material type. You may simply need to perform a find for the desired material type and then the script trigger will switch you to the correct layout.

                    • 7. Re: Restricting records in a layout

                      Ok, thanks.