Igor/10Tec
2016-11-10T10:08:13Z
Some developers faced a problem when the iGrid events AfterAutoGroupRowCreated or CustomGroupValue are not raised in the Microsoft Access development environment. As a rule, this happens when you manipulate iGrid from another iGrid event. For instance, you may group the grid rows from the AfterCellCheckChange event or from an event handler of a custom context menu component attached to iGrid.

It seems, Microsoft Access does not 'like' events containing Variant arguments, which is true for the aforementioned events. But theoretically it may happen for any other event of iGrid. Eckhard Petersen found a universal solution to this problem. We publish his solution below with his consent.

The idea is to duplicate a strongly-typed iGrid reference with the WithEvents clause on the form module level and use this object variable instead of the form control to create event handlers in the VBA code editor. For example, you have an iGrid control named iGrid0 on your form. Let’s suppose you already wrote an event handler like this:

Private Sub iGrid0_AfterAutoGroupRowCreated(ByVal lRow As Long, ByVal lItemCount As Long, ByVal vAggrFuncValues As Variant)
End Sub


Following Eckhard’s solution, we should declare the following variable somewhere at the top of the form module:

Private WithEvents xGrid As iGrid


And then initialize it in the Form_Load event:

Private Sub Form_Load()
    Set xGrid = iGrid0.Object
End Sub


After that we can change the AfterAutoGroupRowCreated event handler to the following one to make it work in all cases:

Private Sub xGrid_AfterAutoGroupRowCreated(ByVal lRow As Long, ByVal lItemCount As Long, ByVal vAggrFuncValues As Variant)
End Sub


And so on, use the xGrid variable to write event handlers for the corresponding form control.

One interesting observation. If you look at the list of the available iGrid events for our “x” object in the Procedure combo box in the VBA code editor

Event list for WithEvents iGrid.png

, you will not find the specific MS Access events Enter, Exit, GotFocus, LostFocus, Update provided by MS Access for the iGrid object hosted on its form. Actually, you will see only native iGrid events in that list.

This solution can be considered as a better way to enable the IntelliSense list for iGrid objects in the code editor described in the following KB article:

IntelliSense list in MS Access VBA 

In fact, you will define the strongly-type iGrid object only once and use it everywhere in the form module without declaring and initializing the iGrid variable in every sub.
RaymondC
2017-01-13T22:50:41Z
I am using your suggestion but have a small problem.

I have not finished upgrading all my iGrid controls to version 6 so I still have some that are version 5. How do I choose the correct version in my declaration statement?

Thanks.

Ray

222.jpg
Igor/10Tec
2017-01-16T14:48:55Z
Preface the control type (iGrid) by the required library name (iGrid500_10Tec for the iGrid v5.0):

Private WithEvents OpenSalesOrderList As iGrid500_10Tec.iGrid
RaymondC
2017-01-16T16:34:42Z
Igor/10Tec
2017-01-17T09:19:09Z
We have the THANK button for that 😉