Programming model

Each object in the object model has defined methods and properties you can use in VBA code to manipulate the behavior of the object. Methods and properties for objects are declared using standard VBA object.method and object.property syntax. Most objects also have specific events that specify when associated VBA code executes for the object.

Methods

Methods are actions you can perform for a given object. Methods include opening and closing a window or moving a field in a window. For example, the field object uses the Focus method to move the focus to a different field in the window:

'Move the focus to the salesperson field
SalespersonID.Focus

Properties

Properties are characteristics you can retrieve or set for a given object. Properties include the title of a window, or the value of a field. For example, you can use the Caption property to change the name of a window or field:

'Change the prompt for a field
CustomerMaintenance.CustomerID.Caption = "Patient ID"

'Change the title of a window
CustomerMaintenance.Caption = "Patient Maintenance"

Events

You’ll write the majority of your VBA code within individual event procedures. Each event procedure executes VBA code at certain times for a specific object, such as when the user changes the value of a field, clicks a button, prints a report, or opens a window. You can see these predefined event procedures in the VBA Code window.

For example, BeforeOpen is an event for a window object. This event executes the associated event procedure when the specified window opens. In the following example, the BeforeOpen event executes a procedure when the Receivables Transaction Entry window opens:

Private Sub Window_BeforeOpen()
	SortBy.Value = 3 'Set the sort list to "by Date"
	DocumentType = 7 'Set the document type to "Returns"
End If


Documentation Feedback