Select field values from a view and copy on a different form

Hi to All, I don’t have a lot of experience with LN. I have a MainForm and a Response form with a numeric field “Amount”. Of course each record in MainForm can have several Responses. Now, I would like to sum of all the “Amount” values for each topic and copy the result into a field “Result” in the MainForm. In the MainForm I have the subview “AllSPAss” with the column nr 5 linked to the field “Amount”

I tried with a button in the main form with the following code:

FIELD result:=result;

r:=@DbColumn(“”:“”; “”; “AllSPAss”; 5 );

@SetField( “result”; @Sum( r ) )

It works, but it copies all the values it found in the column 5 … I have no idea how to select only the records related to single topic in the MainForm.

Thanks in advance for your help.

Subject: use @dblookup instead of @dbcolumn

Read the help - @dbcolumn returns … a column :sunglasses:

@dblookup(“”:“nocache”:“”;viewname;key;column)

Where ‘key’ defines the entries returned