4 Replies Latest reply on Jan 8, 2012 4:16 PM by DavidAbrams

    Varying number of images in one container field...how do I do this?

    DavidAbrams

      Title

      Varying number of images in one container field...how do I do this?

      Post

      I am creating a database which includes images taken from the web. Each record will have a container field for these images, but the specific number of images for any individual record will be variable. Some records will have no images while others may have as many as 10. Furthermore, each image needs to have an associated web address so that users can can open the web site from where the images originated.

      Is there an elegant way to do this so that I don't have to create clunky fields such as "image1" "weblink1" "image2" "weblink2" ... "image10" "weblink10"? In other words, is there a way to have the Images container field "swell" to accomodate more and more images without having to create separate fields for each image.

      I appreciate any advice.  

        • 1. Re: Varying number of images in one container field...how do I do this?
          philmodjunk

          Container field can only store one image. They cannot store multiple images. To store multiple images, you will need multiple container fields. The best way to do this is to set up a related table of image records related to your current table. That method permits complete flexibility as any given record can be linked to as many images as you need.

          If you set up this relationship:

          Originaltable::PrimaryKey = ImageTable::ForeignKey

          Count ( Imagetable::ForeignKey )

          Will count the number of images associated with a given record in your original table.

          • 2. Re: Varying number of images in one container field...how do I do this?
            DavidAbrams

             Thanks for the quick reply. So what fields should I create in the Originaltable to accomodate from zero to n images for any given record? (Sorry, I am a newb and need some hand-holding here.)

            • 3. Re: Varying number of images in one container field...how do I do this?
              philmodjunk

              You should research Portals in FileMaker help and any training materials you have on hand. Not only is this likely to be an item that you need to get this to work, it's a basic feature that almost every FileMaker file uses.

              In your Original table, define one field if you do not already have it: __pk_PrimaryKey. Define it as an auto-entered serial number field. (See field options.) The name isn't important. The auto-entered serial number option--which will uniquely identify each record in your original table--is crucial. If you have existing records and you need to add a serial number field, you'll need to use Replace Field Contents (In the Records menu) to update your existing records with serial numbers.

              Then go to Manage | Database | Tables and create a new table. I'll call it Images. It needs at least two fields: _fk_ForeignKey and Image.

              Make _fk_ForeignKey a number field. Make Image a container field.

              Click the relationships tab and set up this relationship:

              OriginalTable::__pk_PrimaryKey = Images::_fk_ForeignKey

              Double click the relationship line and select "allow creation of records via this relationship" for the Images table.

              Now click OK and add a portal to Images on your OriginalTable layout. You need only add the Image field to this portal, but make sure to specify a scroll bar for the portal. If you click into the container field in the bottom blank row of the portal and select Insert Picture from the insert menu, you can insert an image into the related table of images. FileMaker will update the _fk_ForeignKey field for you so that it stores the matching value from the current record's __pk_PrimaryKey field. Each time you do this, a new blank row appears in the portal where you can add the next image for this same record.

              If you then return to manage | database | fields, you can define a calculation field in your original table that uses:

              Count ( Images::_fk_ForeignKey ) to return the number of images you have linked to the current record in your original table.

              • 4. Re: Varying number of images in one container field...how do I do this?
                DavidAbrams

                Thank you for your help. That works perfectly.