August 5, 200817 yr Newbies I have a (hopefully) simple problem in this example script, in which I want to copy 3 fields from 1 record in table1, to create 3 new records in table 2.: Set Variable [$counter; value:1] Go to Layout ["table1" (table1)] Go to Field [table1::tab1field1] Loop Set Variable [$currentfielddata; value:Get (ActiveFieldContents)] Go to Layout ["table2" (table2)] New Record/Request Set Field [table2::tab2field1; $currentfielddata] Go to Layout ["table1" (table1)] /*Now FM has forgotten that I had selected tab1field1, so the next command goes wrong. In my mind it should have gone to the second field that I wanted to copy.*/ Go to Next Field /*Now tab1field 1 is selected instead of tab1field2*/ Set Variable [$counter; value:$counter + 1] Exit Loop If [$counter > 3] /*leading to 3 new records in table2 with only data from tab1field1*/ End Loop Is it possible to return directly to the field in the layout from which I came so that I can step to the correct next field, or is it simpler to just make an array of the data of the 3 fields in table1, go to table2 and process the array into 3 separate records? Thank you very much in advance for your help! Best wishes, Marc Edited August 5, 200817 yr by Guest
August 5, 200817 yr ... or is it simpler to just make an array of the data of the 3 fields in table1, go to table2 and process the array into 3 separate records? That is the way to go. Something along this way: Go to Layout ["table1" (table1)] Set Variable [$MyFieldsdata ; table1::tab1field1 & ¶ & table1::tab1field2 & ¶ & table1::tab1field3] Go to Layout ["table2" (table2)] Loop Exit Loop If [ IsEmpty ( $MyFieldsdata ) ] New Record/Request Set Field [table2::tab2field1; GetValue ( $MyFieldsdata ; 1 )] Set Variable [$MyFieldsdata ; RightValues ( $MyFieldsdata ; 2 ) ] End Loop
August 5, 200817 yr Author Newbies That is the way to go. Thank you Daniele, also for your example! This should definitely get me on the right track! Cheers, Marc
Create an account or sign in to comment