Jump to content
Sign in to follow this  
Greg Hains

"Compacting" repeating fields

Recommended Posts

Good afternoon,

(I'm not sure this is the right section, but seemed the most appropriate that I can find.)

I have three fields ("type", "client", and "expense"). Each field has 10 repetitions. I have a button that will clear out the n'th repetition of all three fields - so the whole line is blanked should the user need to do so.  What I would like to do is then remove that empty line, moving all the data from all subsequent fields "up" one. (n-1), thus keeping the list compact and free of blank lines.

I did write a loop that did this, but it was very clumsy, and thought that somebody may know of a cleaner way using existing functions and smarter (than my-) logic to achieve this please?

Many thanks in advance if anybody has any ideas.

Greg 

Share this post


Link to post
Share on other sites

I would suggest you solve this by changing your structure: instead of repeating fields, use records in a related table. Then you can simply delete a record and the gap in the portal showing the related records will close automatically, without you having to do anything.

Not to mention numerous other advantages offered by having a proper relational structure.

Share this post


Link to post
Share on other sites

Hi Comment,

Thank you, and yes, you are right - a portal would be a better approach.  
The problem here was becoming more theoretical and experimental to me now than anything. :)

Cheers,
Greg

Share this post


Link to post
Share on other sites

Well, in theory, assuming that any repetition of the three fields would be either empty or non-empty in all three of them, you could gather the remaining values into 3 variables using the List() function (which skips empty values). Then loop populating all repetitions  with the corresponding value from the corresponding variable.

But really, this is not the best way, and hasn't been ever since Filemaker went relational in version 3 (1995).

Share this post


Link to post
Share on other sites

Hi Comment,

Thank you. Loud and clear. lol

I am using the portal method and it works fine, but I was revisiting another part of a solution (I inherited) that had the repeating fields and was probably just wasting time trying to find a solution to it.
Let's close this one. I shouldn't be wasting time anyway.  :)

Thanks again.
Greg

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.