|Title:||RW - Adding Line Numbers to SOP Documents Example|
The following example shows how easy it is to use VBA to add a line number to a SOP Document.
There is a Knowledge Base (KB) article 857285 which uses the Line Item Sequence field and dividing its value by 16384 to obtain a line number. This works... well ... sort of. As soon as a line item has been deleted or inserted, the Line Item Sequence field for the lines in the document will no longer be multiples of 16384 and so this method will start producing incorrect results. This VBA example will always work.
By adding a blank calculated integer field to the SOP Blank Invoice Form at the beginning of the line item, we can then use VBA to populate this field with a value incremented as each line is printed. We use the Report_Start() event to reset the counter variable and then use the Report_BeforeAH() event to increment the counter variable and update the calculated field.
NOTE: To ensure that only the H2 section is incrementing the counter, we use a select case statement in the Report_BeforeAH() event.
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.
|Category:||TIPS AND TRICKS BY MODULES: SOP|
|Date Added:||June 17, 2010 02:12:44 AM|