Microsoft KB Archive/920195

= How to programmatically add a comment line to a document in Small Business Accounting =

Article ID: 920195

Article Last Modified on 2/6/2007

-

APPLIES TO


 * Microsoft Office Small Business Accounting 2006 Software Development Kit 1.2
 * Microsoft Office Small Business Accounting 2006
 * Microsoft Office Small Business Management Edition 2006

-





Notice
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.



INTRODUCTION
There are certain documents in Microsoft Office Small Business Accounting that can contain comment line items. Comment line items are used to enter miscellaneous comments in the document. You can add comment line items programmatically by using the Small Business Accounting Software Development Kit (SDK). To programmatically add the comment line items by using the SDK, you must add an instance of IDescriptionLine to the document.



MORE INFORMATION
The following code sample creates a new purchase order in Northwind Traders. Northwind Traders is the fictitious company that is used for demonstration in Small Business Accounting. Two line items are then added to the purchase order. The first line item is an item line. The second line item is a comment line. ISmallBusinessInstance iSbi = // Initialize iSbi

// This code contains hard-coded values that work with Northwind Traders, the sample product company.

// First, retrieve the vendor for the purchase order. IVendorAccount vendor = (IVendorAccount) GetAccountByName(iSbi.VendorAccounts, &quot;Novelty Bikes&quot;);

// Now, we create the purchase order. IPurchaseOrder po = iSbi.CreatePurchaseOrder; po.FinancialDateTime = DateTime.Now; po.VendorAccount = vendor;

// This is the item that we add to the purchase order. IItemAccount item = (IItemAccount) GetAccountByName(iSbi.ItemAccounts, &quot;Baseball Bat&quot;);

// We add one item line and one description line. // First, we add the item line. IItemLine itemLine = (IItemLine) po.CreatePurchaseOrderLine(DocumentLineType.ContractItemLineType); itemLine.LineItem = item; itemLine.Quantity = 1;

// Now, we add the description line. IDescriptionLine descLine = (IDescriptionLine) po.CreatePurchaseOrderLine(DocumentLineType.ContractDescriptionLineType); descLine.Description = &quot;this is our comment&quot;;

po.Save;

static IAccount GetAccountByName(IBaseMasterView view, string acctName) {   IAccount account = null; DataRow row = null;

if (view != null) {       DataView dv = view.DataView;

// Make sure that there is a column that is named Name, or we receive a runtime exception. if (dv.Table.Columns.Contains(&quot;Name&quot;)) {           dv.RowFilter = String.Format(&quot;Name='{0}'&quot;, acctName); }       // The IJobAccount does not have a Name column; therefore, we search on JobName. else if (dv.Table.Columns.Contains(&quot;JobName&quot;)) {           dv.RowFilter = String.Format(&quot;JobName='{0}'&quot;, acctName); }       // Make sure that there is a column that is named ModifiedDateTime, or we receive a runtime exception. if (dv.Table.Columns.Contains(&quot;ModifiedDateTime&quot;)) {           dv.Sort = &quot;ModifiedDateTime DESC&quot;; }       // In case there is more than one row, we obtain the latest one. if (dv.Count > 0) {           row = dv[0].Row; }   }

if (row != null) {       account = (IAccount) view.GetByDataRow(row); }

return account; }

Additional query words: PO SBA

Keywords: kbexpertiseadvanced kbhowto KB920195

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.