The parent database is Orders, the element OrderNumber is the unique identifier. The subform is named LineItems, and it has a field named ParentOrder that contains the OrderNumber of its parent. Using natural linking, but in the habit of referencing the parent anyway. The subform records have a number element named SortNo that is generated automatically when added. That is the element I want to sort on, ascending order.
Here is the code I am using:
// Sort Line Item record set
// SBasic codes: Search_AND=0, Search_OR=1, Syntax_QA=2, Syntax_REGEX=3
// vKey = @ResultSetSearch(@FN,"ORDERLINES",0,2."!ParentOrder = OrderNumber")
vOrdersSet = @xResultSetForm("ORDERS")
vLinesSet = @xResultSetForm("ORDERLINES")
xResultSetSort(vLinesSet, "SortNo:-1")
//Reparent line Items to new Order
xResultSetReparent(vOrdersSet, "OrderNumber", vLinesSet)
xResultSetClose("ORDERLINES")
xResultSetClose("ORDERS")
I tried the xResultSetSearch and had no luck, so I then tried the xResultSetForm, still not sorting.
I am using the above code to sort records in a subform. Tried to retrieve subform records where the ParentOrder element on the sub form matches the OrderNumber element on the parent form. When the xResultSetMatch did not work, I tried using the xResultSetForm. I am doing this with only one Parent record in the current result set (in the Add Mode) and one-fifteen records in the subform result set.
And finally I want to reparent them because I have changed values in the key elements.
First time using xResultSet commands, but think this should work without putting into a loop? Tried using the examples in the manual, but need some assistance here, thanks.
The sorting is definitely not working, And I'm not sure how to test the natural reparenting.