# Auto-Enter from Calculation Problem

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

## Recommended Posts

I'm trying to figure out a way of creating an auto-enter-by-calculation text field that will do the following:

Auto-enter one of three different values in a field, using the following criteria: If no records in a set contain the text "Current Use", then "Current Use", will be the auto-entry. If there is already a record containing that value, then I'd like the next new record to auto enter "Transfer of Ownership" into the field unless a record in the set already has that value. And then, if there are already records in the set that contain those values but they don't contain a 3rd value "Building Permit", then "Building Permit" is the next value.

Now if all 3 values exist in a set of records, auto-enter will be a blank. But, if any of the values are deleted from a set, the calculation will automatically enter the missing value(s).

Any help is humbly appreciated

##### Share on other sites

So we're looking at a found set not the entire file?? This determins what's going to be filled in the same field in the next record created. Admitted I've never heard of such an algorithm before - can you explain the reasoning in such. How do you make the found set?? Aren't you going to make the found set gathered with a selfjoin relation - but on which field?? From that investigate the dynamic valuelist on the fieldvalue for this found set etc.. I'm not quite sure you have the best solution model for the task at hand - but I could be mistaken?? Please descripe the scenario in plain words!!

--sd

##### Share on other sites

Maybe I'm pursuing the wrong method (auto-enter by calc) for what I'd like to achieve, so I'll just tell you what I want to end up with.

I'd need a minimum of 3 records in any given found set of records. In a field called [color:"red"] _event I'd like to somehow ensure that the value "Current Use" is in at least one of the records. In the same field I'd like the value "Transfer of Ownership" in at least one of the records in the found set, same thing with a record with "Building Permit" in the field. FYI There can be infinitely more than three records to a found set, and it doesn't matter what the value of the field is in the extra records provided that the minimum of three records I described exist in that set.

The problem at hand is that if a found set of records that does not contain these three records with their fields set accordingly, it doesn't make any sense in the end result, which is a report related to the usage of developed properties (land w/structures on it).

I hope this makes sense.

##### Share on other sites

Does the attachment work for you?

kentsAutoEnter.zip

##### Share on other sites

The attachment only enters "Current Use" every time. I delved into it and I get the part about using values from a value list from the self-relationship, but I'm lost after that. I don't think I've ever used the function "Position" before and I'm having difficulty grasping the logic behind it.

##### Share on other sites

It should work, if you are using the button. Creating a record using Ctrl-N or via the menu will not work since it requires a script to capture the ids for the found set to determine whether the desired phrases appear. You could use EventScript, however, to trigger the script to run when a record is created.

Position( text, "something", 0, 1 ) returns the position of the first occurrance of "something" in text. I'm using it as a boolean here. Not Position( text, "something", 0, 1 ) means Position returns the value zero and "something" does not exist in text.

##### Share on other sites

I'm using the button exclusively and every new record shows "Current Use" in the _event field.

##### Share on other sites

The original works. I just downloaded the attachment, and it works also. I can't replicate the problem. For the heck of it, try adding a Commit Records/Requests step after the Paste and see if it performs any differently.

Are you starting with a null record set?

##### Share on other sites

I decided to download your attachment again because I figured me asking you if it works is kind of a dumb question, and no offense intended, please. And gadzooks, this time it works. Now I'm completely baffled. Have you ever heard of this happening? To make matters worse I replaced the original download with the second, so I can't compare the two. I'm going to try to reenact the chain of events when I downloaded the first one. If I can figure out what happened I'll let you know.

Anyway, thanks a bunch for you help -Queue-! Figuring out the workings of the calculation should keep me busy for a while.

##### Share on other sites

I replicated the circumstances that caused the problem I encountered with the original download. I opened the file while it still resided in my Windows Temporary Internet Files. It wasn't modifiable running from the (unzipped?) folder so I did a SAVE AS to the desktop and opened that file. Meanwhile the original file was still open, and that seems to be the cause of the problem. I think that the Get(FileName) in the calculation was getting the wrong one.

Thanks again for your help and patience!

##### Share on other sites

You're welcome. Glad you figured out the problem.

##### Share on other sites

Nice one!!! - If it's what Kents is after. However must measures to ensure the clipboards contents be made!!!

Eventhough something along the lines of http://www.mogulsoft.com/fmpro/clipsave.zip could be done do I recall BruceR listed some exceptions to objects being saved in the clipboard, that looses thier attributes by such a scheeme ...but it might be changed with the new storage of rich texts in fields???

--sd

##### Share on other sites

A Set Field loop can be used in place of Copy All Records, if desired. Then the clipboard is untouched.

##### Share on other sites

Good points! I considered changing the copying to setting when I first looked at the solution. S

##### Share on other sites

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

## Create an account

Register a new account