Page 1 of 1

Sequential Numbering Subform Grid Rows

Posted: Fri Aug 11, 2023 12:02 am
by treed
With a grid subform is there a way to populate new rows with a sequential number starting from 1 as they are added? Or if it would be easier, set the value after a selection is made?

Re: Sequential Numbering Subform Grid Rows

Posted: Fri Aug 11, 2023 8:01 am
by steven
Hi treed,

Add this event to your subform...
afterinsertrow.PNG

And put this js on the Form...

item_sf = subform name
seq_id = id for subform autoid

Code: Select all

function addAuto(){
    
    var a = nuSubformObject('item_sf').rows.length;
    var i = '#item_sf' + nuPad3(nuSubformObject('item_sf').rows.length - 1) + 'seq_id';
    
    $(i).val(a).addClass('nuEdited');
    
}

Steven

Re: Sequential Numbering Subform Grid Rows

Posted: Fri Aug 11, 2023 7:30 pm
by treed
Thanks Steven, Once I figured out that the subform name was the subform object name on the main form and not the subform itself, this code works.

However the way it works is that the first row is not numbered and the next row to be inserted is given the correct number. What I'd like to do is either set the value to 1 for the first row or just number the current row, which ever is easier. Any ideas?

Re: Sequential Numbering Subform Grid Rows

Posted: Fri Aug 11, 2023 7:35 pm
by treed
Ah figured it out. This now numbers the edited row.

Code: Select all

    var a = nuSubformObject('BuildPac').rows.length - 1;
     var i = '#BuildPac' + nuPad3(nuSubformObject('BuildPac').rows.length - 2) + 'OrdPacBoxNumb';
    $(i).val(a).addClass('nuEdited');