Ade Miller
Summit Software Company
December 1999
Summary: Details the programmability models against which the VBA programmer writes customizations. Discusses:
The VBA programmer writes customization code against an object or programmability model specific to the application. VBA also provides an object model for the MT Designer, which is also discussed in this document.
MT VBA Projects can sink four events off of an intrinsic object called ApplicationInstance. One of these events, OnConnection, is used to pass the object model of the application in. The project can then sink events off of that object to respond to events relating to that application. The Modifier client automatically adds boilerplate code to new MT Projects to create a local copy of the passed in application object.
Called when the VBA runtime first loads the MT project DLL when IVbaMt::LoadAllRegMTDlls or IVbaMT::LoadMTDll are called.
Public Event Initialize()
Called when the VBA runtime unloads the MT project DLL when
IVbaMTDlls::Release or IVbaMTDll::Unload are called.
Public Event Terminate()
Called when the VBA runtime first loads the MT project DLL in IVbaMt::LoadAllRegMTDlls or IVbaMT::LoadMTDll. This call provides the object model of the app for the project. The project then should keep a reference to the application and sink events off of it.
For the order programmability model:
Public Event OnConnection(ByVal Application As _
VbaOrderObjectModel.Application, _
ByVal MTDllInst As Object, Custom() As Variant)
For the buyer programmability model:
Public Event OnConnection(ByVal Application As _
VbaBuyerObjectModel.Application, _
ByVal MTDllInst As Object, Custom() As Variant)
Called when the VBA runtime unloads the MT project DLL when
IVbaMTDlls::Release or IVbaMTDll::Unload are called.
Public Event OnDisconnection(Custom() As Variant)
Returns an Order object that represents the order that the customer submitted.
Public Property Get Order() As Order
Order: The order that the customer submitted.
Allows the VBA programmer to abort the transaction by setting the Cancel parameter to True.
Public Event InsertOrderStart(Order As ADODB.Recordset,_
ByRef Cancel As Boolean)
Should allow the VBA programmer to abort the transaction.
Public Event InsertOrderEnd()
Write an event to the Windows Application Event Log.
Public Sub LogEvent(ByVal LogBuffer As String, ByVal EventType As _
DbEventTypes)
Allows the VBA programmer to raise an error that is passed back via the BLL to the host application. Raising an error implicitly aborts the current transaction.
Public Sub RaiseError(ByVal Number As Long, _
ByVal Description As String)
Returns the total number of outstanding POs for the employee that submitted the order.
Public Property Get TotalOutstandingPOs() As Long
Long: The count of outstanding purchase orders for that employee.
Returns the alias associated with the employee placing this order (the alias is the employee's user name).
Public Property Get EmployeeAlias() As String
String: The alias of the employee placing the order.
Returns the ID of the employee placing the order.
Public Property Get EmployeeId() As Long
Long: A unique identifier (actually the primary key ID in the database) representing the employee placing the order.
Returns the date that the order was submitted.
Public Property Get OrderDate() As Date
Date: The date that the order was submitted.
Returns the ID of the order being placed. This ID is generated when the order is inserted into the database, so before the order ends up in the database (that is, on the InsertOrderStart event), the ID is –1.
Public Property Get Id() As Long
Long: A unique identifier (actually the primary key ID in the database) representing the order, or –1 if the order is not yet in the database.
Returns a collection representing the books in the order. Each member of this collection represents a specific book title in the order.
Property Get OrderItems () As OrderItems
OrderItems: Returns the collection representing the items in the order.
Returns the ID of the store for which the order is being placed.
Public Property Get StoreId() As Long
Long: A unique identifier (actually the primary key ID in the database) representing the store for which the order is being placed.
Returns the ID of the supplier from which the order is being placed.
Public Property Get SupplierId() As Long
Long: A unique identifier (actually the primary key ID in the database) representing the supplier from which the order is being placed.
Returns the total number of books ordered.
Property Get TotalBooks() As Long
Long: Returns the total number of items in the order.
Returns the total value of the order.
Property Get TotalPrice() As Currency
Currency: Returns the total monetary value of the order.
Returns the number of unique titles being ordered.
Property Get Count() As Long
Long: Returns the total number of unique titles being ordered.
Returns a specific order item.
Function Item(index) As OrderItem
OrderItem: Returns the specific item in the collection.
Returns the author of the book ordered.
Property Get Author() As String
String: Returns the author of the book ordered.
Returns the ID of the book ordered.
Property Get Id() As Long
Currency: Returns the ID (actually, the primary key in the database) of the book being ordered.
Returns the ISBN number of the order.
Property Get ISBN() As String
String: Returns the ISBN number of the order.
Returns the price of this order item (the price per unit times the number of units ordered).
Property Get Price() As Currency
Currency: Returns the price of this order item.
Returns the title of the book ordered.
Property Get Title() As String
String: Returns the title of the book ordered.
Returns the price per unit of the book being ordered.
Property Get UnitPrice() As Currency
Currency: Returns the price per unit of the book being ordered.
Returns the number of copies of this book being ordered.
Property Get UnitQuantity() As Long
Long: Returns the number of copies of this book being ordered.
Returns the year this book was published.
Property Get Year() As Long
Long: Returns the year this book was published.
This event is called when attempting to calculate the performance of any given employee. The VBA programmer is free to use the incoming data to rate the employee in the manner that they see fit.
Public Event CalculatePerformance (ByVal EmployeeId As Long, _
ByVal EmployeeAlias As String, ByVal Orders As Long, _
ByVal OrderValue As Currency, ByVal OrderVolume As Long, _
ByVal OrderDelay As Long, ByRef PerformancePoints As Long)
Returns the total number of orders between the StartDate and EndDate of GetBuyerPerformance.
Property Get PeriodOrders() As Long
Long: Returns the total number of orders for that period.
Returns the total value of sales for all employees between the StartDate and EndDate of GetBuyerPerformance.
Property Get PeriodOrderValue() As Currency
Currency: Returns the total value of sales for that period.
Returns the total number of books sold by all employees between the StartDate and EndDate of GetBuyerPerformance.
Property Get PeriodOrderVolume() As Long
Long: Returns the total number of books sold in that period.
Returns the average delay between the StartDate and EndDate of GetBuyerPerformance.
Property Get PeriodAverageDelay() As Long
Long: The average delay between orders.
Returns the total number employees placing orders between the StartDate and EndDate of GetBuyerPerformance.
Property Get Employees() As Long
Long: Returns the total number of employees placing orders in that period.
Returns the start date for the performance period.
Property Get PeriodEndDate() As Date
Date: The start date for the performance period.
Returns the end date for the performance period.
Property Get PeriodEndDate() As Date
Date: The end date for the performance period.
Returns the number of days in the performance period.
Property Get PeriodLength() As Long
Long: The number of days in the performance period.