Create Record Button in a Table > Create R. to a Subtable
Hi,
I thougt this would be easy, an that I have done similar before, but now I'm stuck.
I Have a table "Placenames" , with a Subtable "Farms_Places", whitch have all the sub-places under the main Placename.
I have over 1000 records in the Main "Placenames". I have created "Farms_Places" Records manually for ca. 200 of those. Now I want a "for i to loop" button in the "Placenames" table, or in the "Farms_Places" Subtable if that is easyer. The button should create one "dummy" record in the "Farms_Places" Subtable for all the "Placenames" records that have null "Farms_Places". It only needs to add "Dummy" or whatever in a Text field "PlaceNR" in the "Farms_Places" subtable.
I have tried this Button in the "Placenames" Table, but i only create hundreds (# of c count) of Records in the Record that I'm currently at. I am obviously missing something here.....
let n := (select Placenames where Farms_Places = null);
let c := count(n);
for i from 1 to c do
let it := item(n, c);
let nr := (create Farms_Place);
nr.(Placenames := t) + nr.(PlaceNR := "Dummy")
end
4 replies
-
You can try something like this in a button in Placenames:
let n := (select Placenames where Farms_Places = null); for loop1 in n do let nr := (create Farms_Place); nr.(Placenames := loop1; PlaceNR := "Dummy" ) end
Line 1 creates an array that you can use directly in your loop command, so you can skip the count and the item() function.
So now that we are using records directly we can link using the for loop variable (line 4).
If you want to use your code you can modify this way:
let n := (select Placenames where Farms_Places = null); let c := count(n); for i from 1 to c do let it := item(n, i); let nr := (create Farms_Place); nr.(Placenames := it PlaceNR := "Dummy" ) end
You had the variable c in line 4 when you should have used the for loop variable of i. That is why I use the variable name of loop1. It helps me keep track of which loop I'm in (I have some code that have 4 or 5 loops).
I think you mistyped line 6 when you put "t" instead of "it".
Give it a try and let us know how it goes.
-
Thanks Fred, this worked perfectly.
And yes, I had a couple typos in the script I posted, it was a copy/paste/translate error.
said:
let n := (select Placenames where Farms_Places = null);
for loop1 in n do
let nr := (create Farms_Place);
nr.(Placenames := loop1;
PlaceNR := "Dummy"
)
end
Content aside
- Status Answered
- 1 yr agoLast active
- 4Replies
- 110Views
-
3
Following