Create a relation between table A and table B named a_to_b that has the primary key in table A equal to the foreign key in table B. Create a form based on table A. On the form place a “Save” button with the following method:
In the method editor have a look at the Database Manager node and then the function copyMatchingColumns. I believe it does what you are trying to accomplish.
//Copies all matching non empty columns (if overwrite boolean is given all columns except pk/ident, if array then all columns except pk and array names), returns true if no error did happen
for( var i = 1 ; i <= foundset.getSize() ; i++ )
{
var srcRecord = foundset.getRecord(i);
var destRecord = otherfoundset.getRecord(i);
if (srcRecord == null || destRecord == null) break;
databaseManager.copyMatchingColumns(srcRecord,destRecord,true)
}
The method Jan,suggest, does copy matching columns if you have a record on both sides.
It seems to me that the destination, has not any records at all?
You have to create them first!
for( var i = 1 ; i <= foundset.getSize() ; i++ )
{
var srcRecord = forms.ABC_Compare.foundset.getRecord(i); //src foundset
var destRecord = forms.abc_1.foundset.getRecord(forms.abc_1.foundset.newRecord()); //dest foundset
if (srcRecord == null || destRecord == null) break;
databaseManager.copyMatchingColumns(srcRecord,destRecord,true)
}
//Save ANY outstanding change to dest foundset
controller.saveData();