Jump to content

How to reset quickly Repetition fields (bis)


This topic is 5705 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Sorry for this duplicate topic. Problem with the uploading of the original.

I need help. How to reset (to 0, to empty) all the repetitions of a field, in the active selected record) without looping through aleachl repetition with a counter. This takes too long if I need to "reset" multiple such repetirive fields (which are fields of the primary table of my database)

Thank you for help.

Link to comment
Share on other sites

In other words, repeating fields can't be reset without a loop or explicit Set Field[] or Clear for each repetition.

But with a relational structure, there are several ways.

Link to comment
Share on other sites

If you need to clear the contents of the the field in every single record, go to the define database screen and change the field type. The database will warn you that all the contents of the field will be lost, and you can say goodbye to all that data.

If however you need to empty the fields on only some records, and this is something you will be doing on a regular basis as part of your solution, it may be time to change the repeated field into a related table and then transfer the data.

Don't forget to backup before trying anything.

Link to comment
Share on other sites

Since you're on mac os could you however use the developers knowledge of how many repeating fields exists in the field in question. If say you have 10 repeaters in a field:

Commit Records/Requests [ Skip data entry validation; No dialog ] 

Perform AppleScript [ Native AppleScript: show current record set cell 1 of document 1 to {"", "", "", "", "", "", "", "", "", ""} ] 

Show All Records  

By speaking to "document" are you only deleting the value in the current record...

But, hear it from the horses mouth...

Though I will gladly take on any AppleScript project and have complete confidence in the outcome, I never include AppleScript in a FileMaker project and strongly recommend you do not either, though it pains me to do so. The reason is simple: AppleScript only works on Macs. FMP is a cross-platform environment. Even if you are working in an all-Mac environment, sooner or later a Windows machine will be thrown into the mix, or you will decide to make your solution more broadly available. Either way, your AppleScript efforts will be made useless. Whatever you build in FileMaker has to work on both platforms. Period.

...snipped from http://www.foundationdbs.com/Downloads/WhitePaperForFMPNovices.pdf ...where repeating fields as well BTW get's put into perspective.

--sd

Edited by Guest
It makes no sense to delete the content of first record only :)
Link to comment
Share on other sites

How to reset (to 0, to empty) all the repetitions of a field, in the active selected record) without looping through each repetition with a counter.

There is a way to do this, although you really should analyze your use to see if a related table would be better.

Create a calculation field BLANK_REPEAT that is set to "" (or 0, if you prefer). Now, mark its repetitions (below the calc box in Define Field) to the maximum number of repetitions in the fields you want to blank out. Now, create a Number field called "ResetRepeat". Create a field called "_Default" (or whatever) that is a calculation equal to 1. Now, make a Relationship called "ResetRepeat" from the ResetRepeat field to the _Default field (new table occurrence). Make the Repeating Field you want to clear have an Auto-Enter that does a Lookup to the ResetRepeat relationship. You'll pick the BLANK_REPEAT field, and MAKE SURE you uncheck the "Don't copy if empty" (that IS the whole point), and set If No Exact Match to "Do not copy."

Now, to clear that repeating field, you just set ResetRepeat to 1.

You could obviously extend this in various ways to clear out other fields. I haven't done speed testing on this, but I'm assuming it's faster than a loop. If you speed-test it and it isn't faster, let us know here.

Link to comment
Share on other sites

This topic is 5705 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

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