Henrik
2016-09-29T13:19:56Z
I have a grouped grid that is "bound" to a data source. I'm using MS Access 2010.

In the AfterAutoGroupRowCreated I change the font of the grouped rows, set RowIsGroup to false and print aggregated values in corresponding columns.

The problem I'm having is updating the grouped row when something changes. I update data in my tables and reload the grid in AfterCommitEdit.

When I reload the grid in AfterCommitEdit the AfterAutoGroupRowCreated-event is not triggered. If I use a button to call the exact same reload-function everything is fine.

I've made a small sample that demonstrates the problem.

  AutoGroup.zip (158kb) downloaded 202 time(s).
Igor/10Tec
2016-09-30T07:54:40Z
Other developers have already found this glitch in MS Access:

AfterAutoGroupRowCreated not always called 

Note that this happens only in MS Access. This event works as expected in all other development environments.

To solve the problem, I suggest doing the same work another way. As for me, I do not like the idea of reloading iGrid in the AfterCommitEdit event. In fact, you try to replace the grid contents while iGrid is finishing the editing of the current cell. The related internal algorithm has not finished yet, and iGrid still 'thinks' it has the same cell, the same row and column set, etc. What happens if these things are changed? This may cause unpredictable results, and even a crash in the general case.

To avoid this, launch a timer in AfterCommitEdit and perform your reloading/updating in the timer's event. In this case these actions will be done OUTSIDE of AfterCommitEdit, when it has completely finished.

Another idea is to recalcualte totals manually without reloading the grid. Your grid has a simple structure (at least, in the attached demo), and I think you can write this recalcualtion algorithm easily. But sure, this will work only if your users are not allowed to change the values you group by.
Henrik
2016-09-30T10:47:59Z
The approach with using AfterContentsGroup instead as suggested in the other thread has the same problem.

I added a loop in the load-procedure that sums and formats grouped rows after all rows have been added and the content has been grouped. Calling the load-procedure from AfterCommitEdit hasn't given me any problems so far.

Thanks for the guidance.

/Henrik

Igor/10Tec
2016-11-10T11:27:19Z
A solution to this problem has been found. Read this KB article:

iGrid events are not always raised in MS Access