"previous record" is a bit inexact here.
The previous record could be the record you created a few moments before this one. In which case there's a keyboard shortcut (ctrl-' on windows) that copies data into the field in which you have your cursor from the same field in the previous record. This won't work for the first record you create after opening the database, however, just subsequent records.
"previous record" could be the record with a serial number one less than the current record. A relationship could be set up to auto-enter data from this record.
"previous record", just before it in the current found set. In this case, GoToNthRecord can be used to refer to the previous record.
Which situation best matches yours? (and none of these require a script as they can be done with auto-enter calculations which will enter initial data, but still allow you to change the data when needed.)
You could make Description a value list based on itself and have it show only related values using a self join relationship based on GroupName. Make the field a drop down based on that value list and it will allow you to select from the Descriptions entered from any other records with the same GroupName.
Or you could perform a find on GroupName then use replace field contents to set the Description for all of the records with that GroupName.
Thanks for answers. I didn´t mentioned that field GroupName is calculation field and set up automatically. In first record where this calculated result appears, field Description must be written. Like "1KK001EN" (GroupName) impact so that Description is same until Groupname changes. When GroupName changes again, Description must be write again.
PhilModJunk wrote "previous record", just before it in the current found set. In this case, GoToNthRecord can be used to refer to the previous record.". Can You give me example.
Mark Gores wrote "Or you could perform a find on GroupName then use replace field contents to set the Description for all of the records with that GroupName." Can You give me example.
So...my problem is (Description)
- Check to see if the Groupname in this record matches the previous record.
- If it does, set itself to the same value it has in the previous record.
- If it does not, set itself to "ei määritetty"
I tried to put autoenter calculation in field description_en:
Let ( n = (GetNthRecord(diamo_kultakeskus_1::GroupName_en; Get(RecordNumber) - 1) = diamo_kultakeskus_1::GroupName_en) ;
(Case ( n = 1 ;
Jewelrydescription_en = (GetNthRecord(Jewelrydescription_en; Get(RecordNumber) - 1)); "ei määritetty")
Something goes wrong?
I think the value list solution may work for you. First go to to manage database/relationships. Create another table occurence of your diamo_kultakeskus_1 table and call it GroupnameMatch. Then go to manage Value lists and create new. Set it to use values from a field, select the GroupnameMatch table and Description as the field, and check the use only related values box. Now on your layout select the description field and set it to be a drop down using the new value list.
Once your GroupName field is populated, you can tab into or click in the Description field. If there have been any other Descriptions entered with the same group name, those descriptions will be available to select from or you can enter a new one. If there have not been any entered there will be no options to select from and you can type in a new one. You could also set up the Description field to autoenter a looked up value based on the relationship above and it will populate from the first related value.
Or maybe somthing like this is what you are trying to do:
Set Variable [$GN ; diamo_kultakeskus_1::GroupName_en]
Go to Previous record
If ($GN = diamo_kultakeskus_1::GroupName_en)
Set Variable [$Des ; diamo_kultakeskus_1::Description)
Go to Next record
Set Field [diamo_kultakeskus_1::Description ; $Des]
Thanks a lot Mark. I try. The second advise is script. Must I use script triggers?
Yes, that is a script. You could trigger it with something like a OnObjectSave for the GroupName_en field.
Hello Again. It seems that there is something wrong with script. No error but nothing happens.
Do you have FM advanced? If so turn on the script debugger and data viewer to walk through the script step by step and monitor the variables.
If not you can insert a Show Custom Dialog box and place the variables $GN & $Des in the message block to see what values they are being set to.
An auto-enter calculation could take the place of this script:
IF ( GetNthRecord ( GroupName_en ; Get ( RecordNumber ) - 1 ) = GroupName_en ; Jewelrydescription_en ; self )
Personally, I'd set up a table of GroupNames and jewlerydescriptions and use a relationship based on GroupName to either display or copy the jewleryDescription associated with the specified GroupName.
I did try to say that even a relationship to another table occurence by groupname would make it easier. Either using a lookup or to have a related value list.
If the Description associated with a given group changes frequently during the same data entry session, it might not work, but even then the auto-enter calculation that keeps entering the value from the previous record as long as the group name matches will eliminate the need for a script.
I run the script ( without autotrigger)
The variables $GN & $Des looks to be set right. First record gave error 101, cause it is first and there is no previous. But in second record there was no error. Else there was error message in first record second record got description, but when try second record, third record was empty.
Autotrigger don't work
Ok. I trust You. I made another table occurence and value list. It works, but if there is much descriptions in fields, it is quitescrambling list. (more than 50 desc).
I appreciate your help and dare ask to probe using lookup.