beautypg.com

Kofax DOKuStar Validation User Manual

Page 27

background image

DOKuStar Validation for Ascent Capture

Page

23

If SubField.Name = "Quantity" Or SubField.Name = "SinglePrice" Then

Next, the generic

Field

must be converted to a specialized

TableField

variable:

Set t = Field

This allows you to use methods and properties that only exist for

TableFields

. One of these methods is the

Row

method, that delivers the row in which the cell is in. The cell is passed as a parameter to this method. What we get is
an object of type

TableRow

:

Set row = t.row(SubField)

Within this row, we can access the cells by indexing the row with the column name. Since the cell delivered is
actually of type

Field

, methods like

Value

can be used as with any other field:

totalPrice = Val(row("TotalPrice").Value)

The rest of the code should be clear: If the user enters

Yes

in the message box, the

TotalAmount

column will

be overwritten, else the event will be aborted and the user must type in something again.

There is another approach to dealing with table events: Instead of one event for the table as a whole, you could also
use events for single columns. This is done by setting the event sink variable equal to the column:

Dim WithEvents SinglePriceColumn As FieldType

Private Sub Application_OnProjectLoaded(ByVal App As Application)
Set SinglePriceColumn=
App.Project.DataSet.Schema.DocumentTypes("Invoice").FieldTypes("Table").FieldTypes("SinglePrice")
End Sub

As you can see, below the

FieldType

there is again a collection of

FieldTypes

, that denote the columns.

You now get events for every cell in the

SinglePrice

column:

Private Sub SinglePriceColumn_OnFieldChanged(ByVal Field As Field, ByVal SubField As Field)

The parameter

Field

in this case is the cell, the parameter

Subfield

is unused.

From this cell parameter, the whole table may be accessed by using the

Parent

property, which delivers the

TableField

:

Dim t As TableField
Set t = Field.Parent

Having this table, you can access the rows like in the example above:

Dim row As TableRow
Set row = t.row(Field)

So, using events for the table as a whole or for the individual columns is a matter of preference. The first method
allows handling events for multiple columns alike, while the second method would be used for different event
handling on different columns.