I'm running the following code, and I get the error "Invalid table handle" when parent.relation_add(child_tbl) is run (the first one, but if i comment out that then it occurs on the second as well). countAndCompare_ItemName is equal to a field name in countandcompare_importdata.
Code:
pDlg1.Set_Percent(4,totalsteps) pDlg1.Set_Message("Stage 5/"+totalsteps) DIM res AS P res=create_indexes("a5_import_sum","A5_import_name|A5_import_name") if (res.HasError) then msgbox(res.ErrorText) end if res=create_indexes("countandcompare_importdata",countAndCompare_ItemName+"|"+countAndCompare_ItemName) if (res.HasError) then msgbox(res.ErrorText) end if pDlg1.Set_Percent(5,totalsteps) pDlg1.Set_Message("Stage 6/"+totalsteps) dim parent as P dim child_tbl as P parent = table.open("a5_import_sum") child_tbl = table.open("countandcompare_importdata") relation.link_type = LINK_MANY relation.index_child = child_tbl.index_get(countAndCompare_ItemName) relation.order_parent = "A5_import_name" relation.ref_integrity = 1 parent.relation_add(child_tbl) parent.set_create("import_to_syscount") parent.close() child_tbl.close() pDlg1.Set_Percent(6,totalsteps) pDlg1.Set_Message("Stage 7/"+totalsteps) parent = table.open("countandcompare_importdata") child_tbl = table.open("a5_import_sum") relation.link_type = LINK_MANY relation.index_child = child_tbl.index_get("A5_import_name") relation.order_parent = countAndCompare_ItemName relation.ref_integrity = 1 parent.relation_add(child_tbl) parent.set_create("syscount_to_import") parent.close() child_tbl.close()
Comment