Controller events, Ondocumentactivated, Ondocumentdeactivated – Kofax DOKuStar Validation User Manual

Page 36

Advertising
background image

DOKuStar Validation for Ascent Capture

Page

32

Controller Events

The controller object itself is described below in a separate chapter, please refer for a description.

This object gets events when the active object changes, i.e. a field or document gets activated or deactivated. So here
is another potential place to enter the (de)activation code. This is especially useful for routines that are common to all
documents or all fields.

OnDocumentActivated

Will be fired for any document that gets activated.

Definition:

Private Sub ctrl_OnDocumentActivated(ByVal Controller As Controller, ByVal Document As Document,
ByVal PreviousDocument As Document)

Parameter

Document

is the document that gets activated,

PreviousDocument

the one that becomes

deactivated.

OnDocumentDeactivated

Will be fired for any document that becomes deactivated.

Definition:

Private Sub ctrl_OnDocumentDeactivated(ByVal Controller As Controller, ByVal Document As
Document, ByVal NextDocument As Document)

Parameter

Document

is the document that becomes activated,

NextDocument

is the one that will become

activated next.

Example:

Dim WithEvents ctrl As Controller

Private Sub Application_OnProjectLoaded(ByVal App As Application)
Set ctrl = App.Project.DataSet.Controller
End Sub

Private Function ctrl_OnDocumentDeactivating(ByVal Controller As Controller, ByVal Document As
Document, ByVal NextDocument As Document) As Boolean
ctrl_OnDocumentDeactivating = True
If Val(Document.Fields("SinglePrice")) * Val(Document.Fields("Quantity")) <>
Val(Document.Fields("TotalPrice")) Then
MsgBox "SinglePrice*Quantity does not equal TotalPrice, please correct"
ctrl_OnDocumentDeactivating = False
End If
End Function

This example assumes that on every document, no matter which document type, there are fields

SinglePrice

,

Quantity

and

TotalPrice

. A check will be made if

SinglePrice

*

Quantity

=

TotalPrice

.

Advertising