Hi! I’m looking for a way to create a function where on of the arguments belongs to a separate table? table1.field2 = table2.field2, where table1.field1 = table2.field1. This formula (function) would then be called on the OnValidate trigger of “table1.field2” field. Thanks.
hi, I’m not sure if I understood your problem correctly but try it this way: - define a variable, type record for table2 and another one, RecOk, type Boolean - if field1 is the key in table2 then “get” the corresponding value of table2 using the following code: RecOk := table2.GET(table1.field1); this will get the record in table2 for which “table1.field1 = table2.field1” (second part of your statement) - if field1 is not the key in table2 then you need to use setrange: table2.SETRANGE(field1, table1.field1); IF table2.FIND(’-’) then… there might be more than one value in table2 though. - and as a final step, assign the values as wanted: table1.field2 := table2.field2; it’s not very complete (error handling), though it gives you an idea how to proceed. that’s it, hope it helps Nils
Hi Nils, Thanks a lot. It works! Cheers.
Use this code IF table2.get(table1.field1) then table1.field2:=table2.field2;