Microsoft Dynamics GP Developing for Dynamics GP
A blog dedicated to the Microsoft Dynamics GP Developer & Consultant community
 
Welcome to MSDN Blogs Sign in | Join | Help

Developing for Dynamics GP

by David Musgrave (Australia) and the Microsoft Dynamics GP Developer Support Team (USA)

News

  • Please use the Blog Feedback? - Contact Us link at the top of the page to email questions relating to the blog itself.

    If you wish to ask a technical question, please use the links below to ask on the Newsgroups. If you ask on the Newsgroups, others in the community can respond and the answers are available for everyone in the future.

    Please do not use comments on pages and posts to ask questions unrelated to the topic on that page or post.



    Dates of Interest:

    11-Jul-2008: Blog Created by David Musgrave.
    10-Oct-2008: First Post by Scott Stephenson.
    04-Nov-2008: First Post by Dave Dusek.
    11-Nov-2008: First Post by Beth Gardner.
    28-Nov-2008: First Post by Chris Roehrich.
    30-Dec-2008: First Post by Patrick Roth.
    24-Feb-2009: First Post by Greg Willson.
    22-Apr-2009: First Post by David Clauson.
    04-May-2009: First Post by Ryan Wigestrand.
    19-Jun-2009: First Post by Dawn Langlie.
    03-Jul-2009: First Post by Emily Halvorson.



    WorldMaps Statistics since
    24-Feb-2009:






    Translator Tool:




    Disclaimer

    This blog is provided "AS IS" with no warranties, and confers no rights.

    The links in this blog may lead to third-party Web sites. Microsoft provides third-party resources to help you find customer service and/or technical support resources. Information at these sites may change without notice. Microsoft is not responsible for the content at any third-party Web sites and does not guarantee the accuracy of third-party information.

Contents

Favourite Posts

Blog Links

Newsgroups Links

Resources Links

RW - Accessing any SQL data from a Report Example

The following Report Writer and VBA example demonstrates how data from any SQL table can pulled into a report regardless of the product the table is related to.  This technique can also be used when it is not possible to create the table relationship needed to add the report in the Report Writer. It works as long as you can create a query that will uniquely select the data you need based on the data on the report or from the already linked tables.

This example is based on the Manual Payments Posting Journal and MC Manual Payments Posting Journal reports. When the report starts, it uses VBA to obtain a connection via ActiveX Data Objects (ADO) to SQL Server. This connection remains open until the report ends, when the code closes the connection.

In the body of the report the code takes the voucher number of the applied document and runs a Transact-SQL query to obtain the document number for the same document from the PM_Key_MSTR (PM00400) table.  It then populates this new value into a newly created blank string calculated field.

The example is a bit more complicated because these reports are based on temporary tables which re-use the same fields for multiple purposes.  By looking at the other fields in the temporary table (specifically the Sequence Number field) it is possible to identify which records are of the type we want to modify.  For all other records we just pass through the data (for Field2) without making any changes.

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. 

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.

23-Feb-2009: Add Link to How to use an ActiveX Data Object (ADO) with VBA on a report in Microsoft Dynamics GP (KB 954619) Secure Link

13-May-2009: Add link to Using ADO with VBA with Report Writer article.

Posted: Thursday, July 17, 2008 10:36 AM by David Musgrave
Filed under: , ,

Attachment(s): Manual Payments Journal Report.zip

Comments

Developing for Dynamics GP said:

I often get told that it is impossible to customize a report which uses a temporary table, and in particular

# July 25, 2008 2:31 AM

David Musgrave said:

# August 4, 2008 1:01 PM

Developing for Dynamics GP said:

During my time in the partner channel, I worked with a number of consultants who had a number of problems

# September 1, 2008 6:08 AM

Developing for Dynamics GP said:

Most people are aware that you can use Visual Basic for Applications (VBA) with Microsoft Dynamics GP

# October 30, 2008 2:14 AM

Developing for Dynamics GP said:

As a follow on to the Using VBA with Report Writer post, I would like to discuss using ActiveX Data Objects

# October 30, 2008 2:17 AM

GPNUT said:

This works like a charm have been able to implement for several clients... Only thing is there a RetrievealGP10.dll or do you

# December 9, 2008 12:29 PM

Scott Stephenson [MSFT] said:

Thanks for the note GPNUT. For release 10.0, there is no RetrieveGlobals.dll and you would instead use the built-in UserInfoGet object that is available. For GP 10.00 you will need at least Service Pack 1 to use this sample.

# December 9, 2008 12:37 PM

Developing for Dynamics GP said:

One of biggest issues people have with the Microsoft Dynamics GP Report Writer is not being able to create

# May 17, 2009 8:54 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker