Button for writing to another table
Hello
There is a button, in the sub table Cash Desk.Expenses, that should make a record in another table.
to Table ADVANSE
formula for button is
let x := dialog("NEW RECORD", "CREATE NEW RECORD?", ["No", "Yes"]);
if x = "Yes" then
let d := Date;
let xCurrRec := Id;
let xNewName := Name;
let xNewAmounnt := Amount;
let xNewComment := Comment;
let i := (create ADVANSE);
i.(EMPLOYEES := xNewEmploee);
i.(Name := xNewName);
i.(Amount := xNewAmounnt);
i.(COMMENT := xNewComment)
end
as you can see in the second picture, this is a table of employees, and I need it when I make a record using the button, it is written into the personal table of each employee. There is a link to the table Expenses Tab to Employees N:1
Help edit the formula.
Thank you all
5 replies
-
let x := dialog("NEW RECORD", "CREATE NEW RECORD?", ["No", "Yes"]); if x = "Yes" then let d := Date; let xCurrRec := Id; let xNewName := Name; let xNewAmounnt := Amount; let xNewComment := Comment; let i := (create ADVANSE); i.(EMPLOYEES := xNewEmploee); i.(Name := xNewName); i.(Amount := xNewAmounnt); i.(COMMENT := xNewComment) end
Just a tip, since you put the current record Id into a variable, line 4, you can just use that to reference all your fields. So it would look like:
let x := dialog("NEW RECORD", "CREATE NEW RECORD?", ["No", "Yes"]); if x = "Yes" then let d := Date; let xCurrRec := Id; let i := (create ADVANSE); i.( EMPLOYEES := xCurrRec.EMPLOYEES; Name := xCurrRec.Name; Amount := xCurrRec.Amount; COMMENT := xCurrRec.Comment ) end
This should also link the new record in ADVANSE to the proper EMPLOYEE record.
-
said:
What is interesting is that the record is displayed in the "advance" table itself, but it is not in the sub-table that is in the employee account. Records are not linked to an employeeI don't know how your DB is built so I can't help you with specific field names.
What is the name of the reference field in ADVANCE to EMPLOYEES? Use that in your code.
Content aside
- 3 mths agoLast active
- 5Replies
- 52Views
-
2
Following