How to add action to row in grid control

I have a form for a parent table with a subform displaying child records in a grid control. When a row is added to the grid (and a new child record created) I’d like to populate a field in the grid with the next number in sequence for the parent record, e.g. the first child record for this parent gets a 1, the next a 2, etc.

Similar to auto-numbered tables, but resetting for each new parent record. Think line items on a purchase order. In SQL terms, something like:

 select max(LineNumber)+1 as NewLineNumber from ChildTable child where child.OrderNumber = %1;

Is this possible?

I think you could try something along this line: pre-setting value of item #

Option Explicit
Sub Item(evt As Object)
	Dim SF As object, TC As Object, TCItem As Object 
	Dim rn As Integer
	TC = evt.Source.Model.Parent
	SF = TC.Parent ' ref. to the subform
	rn = SF.RowCount + 1
	' get reference to order item#:
	TCItem = TC.getByName("NumericField1")
	TCItem.Value = rn
	print rn
End Sub 

Event When losing focus of control (fk) Order Id.