Thursday, August 5, 2010

From the Blog Archives: Using VBA in Report Writer

I've known for years that the Dynamics GP Report Writer supports VBA.  The theory is that you can add VBA code to Report Writer events, allow you to perform complex calculations, modify field values, or retrieve and display additional data on reports.

I say "known" and "theory" because until today, I had never bothered to try VBA on a report.  I probably should have years ago, but if you've used Report Writer, you can understand my reluctance to spend too much time exploring its exciting features and then be labeled as a Report Writer "expert". 

It turns out that adding custom VBA code to a report is quite easy--once you know how to do it, and how VBA works with report writer.  The documentation for doing so is not in the Report Writer Manual, but is instead in the VBA Developer's Guide document.  It does a fairly good job of explaining the mechanics, and I was able to get some code working in just a few minutes that performed an ADO query of a table outside of the standard reporting dictionary for the report, and displayed that data on each line of the report.

Afterwards, I checked to see if there was a blog post on the process, and sure enough, his eminence David Musgrave has written an excellent post on the topic, providing some great details that were not obvious from my cursory review of the VBA Developer's Guide.

If you haven't used VBA with the Dynamics GP Report Writer, definitely read his post.

No comments: