Removing References to Fields in VBA Revisited

David MeegoMichael Johnson (the MBS Guru) has posted a great article about removing invalid references from a Visual Basic for Applications (VBA) project. This has prompted me to revisit the topic and gather together all the relevant resources from a number of blog authors.

A few months back, Mohammad Daoud published a post on the same subject. His method of removing the window from VBA and re-adding the window and fields back to VBA is the supported method for removing references to fields that no longer exist on the window.

Below are the links to the his article and some of my thoughts at the time:

The Microsoft_Dynamics_GP.vba project references some objects that cannot be found. these objects are listed in the file: C:\Program Files\Microsoft Dynamics\GP\Dynamics.txt. (Mohammad Daoud's site)

Linking Field Prompts and fixing VBA Reference Errors (this site)


However, what happens when you have a VBA customization with many fields added to VBA and only one or two that have been removed and are now causing errors?

You might remember how the Action Button replaced a number of other buttons in the v10.0 Sale Transaction Entry window.  This means that if the old Transfer, Delete, Post buttons etc. were previously added to VBA, they would now cause invalid reference errors.  See the links are the bottom of this post for more information on the Action Button.

Michael recently faced this situation when upgrading a site to v10.0. There were over 60 other fields added to VBA. Using the method mentioned in the previous articles would have required a huge effort to manually add the 60 fields back to VBA.  So Michael used a technique which has been mentioned before and manually edited the exported package file with Notepad.exe.  For the details, please see his post:

Removing a Reference to a Field or Object in VBA (Michael Johnson's site)

NOTE: The technique described here directly modifies the contents of a customization package with Notepad.  This technique is not supported by Microsoft Dynamics GP support.


For information on changing VBA or Dexterity code to work with the Action Button in the v10.0 Sales Transaction Entry (SOP_Entry) window, have a look at these related posts from Mariano Gomez and myself:  

Upgrading SOP Entry VBA Customizations from Dynamics GP 9.0 to Dynamics GP 10.0 (Mariano Gomez's site)

Dex - Working with the Action Button on the SOP_Entry form (this site)

Hope you find this summary useful.

David