How to use the FormsFactory class to open Office Small Business Accounting forms (908017)



The information in this article applies to:

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

INTRODUCTION

This article describes how to use the FormsFactory class to open certain Microsoft Office Small Business Accounting forms that are included in third-party applications.

MORE INFORMATION

You can open certain Small Business Accounting forms if the applications that include the forms run on a computer that has Small Business Accounting installed.

For example, assume that you want users to be able to add a customer dynamically, without re-creating the business logic that is contained in the Small Business Accounting customer form. In this case, you can use the FormsFactory class to open the Small Business Accounting customer form. This feature enables a user to add a customer and then return execution to the application.

The following code examples demonstrate two scenarios. In the first scenario, the FormsFactory class is used to open a blank customer form. This scenario is useful if a user must add a new customer. The second scenario opens the customer form and then loads a specific customer into the form. This scenario is useful when existing customer information must be edited.

Scenario 1

// Log on by using a company name and a server name of your choice.
iSbi.LogOn(companyName, serverName);

// Declare the FormsFactory class.
IFormsFactory iFF = 
	(IFormsFactory) uiAssembly.CreateInstance("Microsoft.BusinessSolutions.SmallBusinessAccounting.UI.FormsFactory");
iFF.Initialize(iSbi);

// Retrieve the customer form with an existing customer loaded.
ICustomerAccount cust = 
	(ICustomerAccount) iSbi.CustomerAccounts.GetByDataRow(iSbi.CustomerAccounts.DataView.Table.Rows[4]);
System.Windows.Forms.Form sbaForm = iFF.CreateForm(cust);
sbaForm.StartPosition = FormStartPosition.CenterScreen;
sbaForm.ShowDialog();

Scenario 2

// Log on by using a company name and a server name of your choice.
iSbi.LogOn(companyName, serverName);

// Declare the FormsFactory class.
IFormsFactory iFF = 
	(IFormsFactory) uiAssembly.CreateInstance("Microsoft.BusinessSolutions.SmallBusinessAccounting.UI.FormsFactory");
iFF.Initialize(iSbi);

// Retrieve the customer form with an existing customer loaded.
ICustomerAccount cust = iSbi.CreateCustomerAccount();
System.Windows.Forms.Form sbaForm = iFF.CreateForm(cust);
sbaForm.StartPosition = FormStartPosition.CenterScreen;
sbaForm.ShowDialog();

Modification Type:MinorLast Reviewed:3/31/2006
Keywords:kbMBSMigrate kbhowto KB908017 kbAudEndUser kbAudDeveloper