Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Igor/10Tec  
#1 Posted : Thursday, November 10, 2016 10:08:13 AM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,114

Thanks: 15 times
Was thanked: 141 time(s) in 141 post(s)
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:

Code:
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:

Code:
Private WithEvents xGrid As iGrid


And then initialize it in the Form_Load event:

Code:
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:

Code:
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.

Edited by user Thursday, November 10, 2016 10:11:40 AM(UTC)  | Reason: Not specified

RaymondC  
#2 Posted : Friday, January 13, 2017 10:50:41 PM(UTC)
RaymondC

Rank: Advanced Member

Groups: Registered
Joined: 6/24/2013(UTC)
Posts: 95
Location: Seattle, WA

Thanks: 2 times
Was thanked: 2 time(s) in 1 post(s)
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  
#3 Posted : Monday, January 16, 2017 2:48:55 PM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,114

Thanks: 15 times
Was thanked: 141 time(s) in 141 post(s)
Preface the control type (iGrid) by the required library name (iGrid500_10Tec for the iGrid v5.0):

Code:
Private WithEvents OpenSalesOrderList As iGrid500_10Tec.iGrid
RaymondC  
#4 Posted : Monday, January 16, 2017 4:34:42 PM(UTC)
RaymondC

Rank: Advanced Member

Groups: Registered
Joined: 6/24/2013(UTC)
Posts: 95
Location: Seattle, WA

Thanks: 2 times
Was thanked: 2 time(s) in 1 post(s)
Thanks.
Igor/10Tec  
#5 Posted : Tuesday, January 17, 2017 9:19:09 AM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,114

Thanks: 15 times
Was thanked: 141 time(s) in 141 post(s)
We have the THANK button for that ;)
thanks 1 user thanked Igor/10Tec for this useful post.
Guus2005 on 6/28/2018(UTC)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.