This is a reposting of an article I originally wrote on my Developing for Dynamics GP blog.
It has been a while since I posted some example code, so here is one which demonstrates how to write back data using ADO.
The following VBA example adds the Item Short Description and Standard Cost fields to the Item Transaction Inquiry window and reports. It also allows the Standard Cost to be edited and updated back to the Item Master table.
The VBA code opens the connection when the window or report is opened and closes the connection when the window or report is closed. The script also uses two record sets, one which is read only to retrieve the fields from the Item Master (IV00101) table and the other to enable the updating of the Standard Cost field.
NOTE: The method of opening an ADO connection to SQL Server differs for each version. v8.00 uses the external RetrieveGlobals.dll, v9.00 use the external RetrieveGlobals9.dll and v10.00 uses the built-in UserInfoGet object. v10.00 will need at least Service Pack 1 to use this sample.
The Knowledge Base (KB) article below demonstrates the different methods:
Example code for v8.0, v9.0 & v10.0 is attached at the bottom of the article.
Please see the “Installation Instructions.txt” file in each version’s archive for more information.
This article was originally posted on the Developing for Dynamics GP Blog and has been reposted on http://www.winthropdc.com/blog.