I've constructed a database to track revenue and expenses on a number of individual funds. The table titled funds has the general info which is stored in a child called balances and then a grand child called revenue. Each fund has an annual record. I've set up a button to begin a new year and it does start the new balance. It creates a revenue record but connect back to the balance child. Here's the code. Any thoughts?


let currentRec := this;
let Nyear := last(Balances.Year) + 1;
let Nbeg := last(Balances.'Temp. Restricted-Total');
let Nperm := last(Balances.'Perm. Restricted-Total');
let i := (create Balances);
i.(Active := "Yes");
i.(Year := Nyear);
i.('Beginning Balance-Temp' := Nbeg);
i.('Beginning Balance Perm' := Nperm);
let j := (create Revenue);
j.('Rev-Amount' := 100);
j.(Notes := "Test Expense");
j.('Rev Date' := now());
i.(Funds := currentRec)