Jump to content
Salesforce and other SMB Solutions are coming soon. ×

How to find the last "Empty" repeating field


Demo92

Recommended Posts

I am trying to put together a calculation field that will find the value of the last "empty" repeating field., i.e: the field following the last "non-empty field".

 

Any Suggestions ?

Link to comment
Share on other sites

Originally posted by Demo92:

[qb]I am trying to put together a calculation field that will find the value of the last "empty" repeating field., i.e: the field following the last "non-empty field".[/qb]

The value of the last "empty" repeating field should be " ". And so would be the field following the last "non-empty field".

:eek:

 

What kind of secrets are you hiding here ?

Link to comment
Share on other sites

Try this script

 

First Empty Repetition

 

Go to Layout [ Data ]

Go to Field [ RepeatingField ]

Loop

 

If [ Left(RightWords(Status(CurrentAppVersion), 1), 1) > "4" ]

Exit Loop If [ IsEmpty(GetRepetition(RepeatingField, Status(CurrentRepetitionNumber))) or

FieldRepetitions(Status(CurrentFileName), Status(CurrentLayoutName), Status(CurrentFieldName)) =

Status(CurrentRepetitionNumber) ]

Else

Exit Loop If [ IsEmpty(GetRepetition(RepeatingField, Status(CurrentRepetitionNumber))) or Status(CurrentRepetitionNumber) = 10 ]

*10 represents the max number of reps *

End If

Go to Next Field

End Loop

Link to comment
Share on other sites

So then, as we are in the Calc and Define Fields Forum....

 

To get the first empty repetition number.

 

t_RepeatingData (could be num)

 

n_repetition (a repeating field holding as many repetitions as the t_RepeatingData)

 

c_ChecksEmpty (calc, repeating)

Case(not Left(Trim(Right(t_RepeatingData &"*" & n_repetition,3)),1)="*","","Rep00"&Repetition)

 

n_FirstEmptyRepetition = Min(c_ChecksEmpty )

Link to comment
Share on other sites

  • 2 years later...

Hi, just joined the forum, great to find this resource.

 

I'm trying to write a script to paste data from one field, Pledges, into the first empty field of a repeating field, Gifts; then paste the current date into the first empty field of another repeating field, Gift Date. I assume I need two separate subscripts, one for Gifts and one for Gift Date. I've tried the scripts and calculations already posted. Chopper's works for Gifts, but when I duplicate the script and change the field names to Gift Date, it goes to the first empty repeating field in Gifts rather than Gift Date. The layout does include all 10 of both fields' repetitions. Ugo Di Luca's solution doesn't work -- the calculation fields remain empty -- not sure why.

 

Thanks in advance for any help,

Angharad

Link to comment
Share on other sites

Hmmm, this is exactly why people don't use repeating fields for much any more. You really should have an additional Gifts table that is related to the table your original repeating field was on, and store each gift as a new record. Using a repeating field in this way will cause all sorts of headaches further on down the road (as well as now).

 

That being said...

Ugo's concept can be shortened to a single repeating field:

 

cLastRepetition:

 

Case(

IsEmpty(YourRepeatingField); Get(CalculationRepetitionNumber))

 

and from your script you would set field:

 

YourRepeatingField[min(cLastRepetition)]

 

-Raz

 

Whoops! Angharad, they did not add Get(calculationRepetitionNumber) until FM7. You probably could still pound this out by adding a second globalrepeating field that had the repetition number in each repetition and used this to fetch the repetition number in the cLastRepetition calc (I avoided rep fields like the plague before FM7, and still do, if used in the way you describe), but it will be much easier to put them in a portal to a related Gifts table.

Link to comment
Share on other sites

Thanks Razumovsky, this is great advice. I have been using FileMaker since it was still owned by Nashoba (late eighties!!) but really haven't kept track of all the improvements and iterations since then. I will read up on portals and try your suggestion, because the alternative is indeed causing me a headache! smiley-smile

Link to comment
Share on other sites



×
×
  • Create New...

Important Information

Terms of Use