22 August, 2010

Filtering Grids in Dynamics GP with Modifier/VBA

It is pretty simple to apply custom filters to grids in Dynamics GP to control the data that loads into Lookups and Transaction Entry Windows.

In this example, my client wanted to be able to filter the Contract Maintenance - Lines window by Item Number and/or Serial Number.  Their contracts can be quite lengthy.  Research and contract maintenance would be cumbersome and inefficient without the ability to filter the records in this window.

To do this, use Modifier to add 2 new Text Boxes to the Contract Maintenance - Lines window in which to capture the filter criteria.  I placed them directly above the grid in the window.


Next, add the Contract Maintenance - Lines window and the following fields to your VBA Project:

  • Item Number and Serial Number in the Grid
  • Item Number and Serial Number fields you added with Modifier
Paste the following code in the ContractMaintenanceLDetail Grid BeforeLinePopulate event:


Now, just click the Redisplay button to apply the filter.


This code will evaluate records as they are populated in the grid and reject those that don't match the filter criteria.  In this case, I used the Like operator so that any records that did not contain the filter criteria would be rejected.

1 comment:

Unknown said...

Hi Michael,

This is exactly what I used to give my clients when they ask for filtering Inactive Customers, Vendors & Accounts in GP10. But as you know, GP2010 has got this as in-built feature now. :-)

Such is the power of Modifier/VBA filtering. If the same is written in Dexterity (reject record), it would take at least 5x times than Modifier/VBA filtering.

Vaidy