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

Page 51

Advertising
background image

DOKuStar Validation Programming Manual

Page

47

Controller Events

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.

OnDocumentDeactivating

Will be fired for any document that becomes deactivated.

Definition:

Private Function ctrl_OnDocumentDeactivating(ByVal Controller As Controller, ByVal Document As
Document, ByVal NextDocument As Document) As Boolean

Parameter

Document

is the document that becomes activated,

NextDocument

is the one that will become

activated next.

Example:

Option Explicit

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 TotalkPrice, 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