Using Barcodes from the Dynamics GP Report Writer

David Meego - Click for blog homepageA few months ago, I worked on a support case where we needed to add a barcode to a Sales Order Processing transaction print out.  We were able to achieve what we needed using Visual Basic for Applications (VBA) to handle some of the scripting for us.  I have been meaning to write a blog post on how to make a customization like this for a really long time and have finally got around to it.  

This post is a good follow up to the Dynamics Report Writer is the Best Report Writer in the World post by demonstrating another cool customization using Report Writer with VBA. I will even use the same style to format the post.

Note: There are a number of different types of barcodes used, this example will use a Code 128 barcode subtype C (aka 128C), however, it does include the code needed for 128A and 128B as well.


The Situation

The customer wanted to use Code 128 barcodes on their SOP Packing Slips for the Item Number so they could be scanned at the warehouse before sending the order out.  The customer had already purchased barcode True Type fonts from a vendor (in our case


The Problem

Using a barcode font is not just a matter of printing the Item Number using a different font.  Barcodes have additional characters added for Quiet Zones and Check Digits (see Wiki post). There is an algorithm required to convert your string into the barcode characters which can then be displayed using the barcode font.

Luckily, the barcode font vendor had provided some example BASIC code designed to be used with Microsoft Office Excel's Visual Basic for Applications (VBA).  As the VBA in Office is almost identical to the VBA in Microsoft Dynamics GP, we were able use their code with almost no changes.


The Solution

So, we added a couple of blank string calculated fields to return our barcode characters to.  One we left as the standard font (for testing purposes) and the other was changed to use one of the barcode fonts installed previously.  Next we used the Tools menu to add the report to VBA, then selected the Item Number and the two newly added calculated fields and added them to VBA.

The screenshot below shows the calculated fields added onto the report layout.

Report Layout showing added calculated fields.


The Code

The code is quite simple.  We just need to call one of the provided conversion functions and return our results to the added calculated fields.

Code from SOPBlankPackingSlipForm Module


The Result

Below is a screenshot of the resulting report. Note the additional characters added to the barcode text:

Example screen output showing populated barcode fields


More Information

The links below provide mode information on the Barcode code 128 and its subtypes as well as a link to the barcode font supplier used by this customer.  The barcode functions included in the VBA code for this example were provided by and are used in this example with their permission.


I hope you find this example of how barcodes can be used on Dynamics GP reports useful. 


Comments (13)

  1. Sandip Jadhav says:


    Are you able to scan these barcode ? I have used barcode fonts on Report Writer to show Sales Order No but not able to scan until I added * on starting and Ending of barcode.


    Sandip Jadhav

  2. David Musgrave says:

    Hi Sandip

    I don't have a barcode scanner to test with, but adding any additional characters is simple from the VBA code.  

    Please note that we are already calling functions to convert the Item Number into the text needed for Code 128 barcodes which is adding additional characters before and after the Item Number.


  3. mlopat says:

    Hey Sandip,

    Having done a lot of work with 1 dimensional and 2 dimensional barcodes, I can say from experience that a lot of users encounter the problem with the asterisk (*) at the beginning and end of the barcode.

    One of the most common problems is that applications like Microsoft Word will change the text from simply a bunch of characters with an asterisk on both sides, into a bold face set of characters. The program thinks you are trying to place emphasis on the text. With the code David is showing, this is not an issue as he is programmatically specifying the format. It’s a good example and should shed some light on just how easy it can be for a Dynamics GP system to start taking advantage of barcodes.


  4. mgomezb says:

    Also, take a look at my article RW – Working with POSTNET barcodes for US zip codes at…/rw-working-with-postnet-barcodes-for-us.html. This article deals with coding the zip codes using the algoritm provided by the US Postal Service.

  5. David Musgrave says:

    Hi Mariano

    That is another great example, thanks for highlighting it.


  6. David Musgrave says:

    Mark seems to have a real dislike for Report Writer….

    Posting from Mark Polino at…/using-barcodes-from-dynamics-gp-report.html

  7. mgomezb says:

    Maybe we should do some Advanced Report Writer at Tech Conference and Convergence… just saying!

  8. Kim G says:

    Can anyone tell me if it is possible to have Great Plains 15 read Micro QR codes rather than linear 128?

  9. Hi Kim

    If your barcode reader works as a keyboard wedge (ie, it inserts characters as though they have been typed), then a QR code reader should work.


  10. great article, thanks you very much

  11. Scott Robling says:

    Great Article David,
    Have you run across VBA code for 2D barcode that I could use just like your 1D barcode? Looking to put on several Dynamics GP 2016 SOP reports that have already been modified. I have not been able to find any code that will allow for the 2D within GP. Many thanks for taking time to assist and provide articles like the above.

  12. Hi Scott

    I don’t think a 2D barcode is possible as I don’t think it can be represented in text characters (which look like a barcode with the appropriate font).


Skip to main content