Validate
Use the Validate event to perform validation on document level. At this point, the validation of all single fields executes. If one of the fields is still invalid, pValid is FALSE. During the Document_Validate event, it is possible to implement validation rules combining several fields. This may cause some fields to be invalid again. Do not make the document invalid if all fields are valid, because the Verifier needs an invalid field for focus control. If you want to keep the document invalid, always set at least one field to an invalid state.
It is also possible to make invalid fields valid during document validation. Therefore, you must set the Valid property of the appropriate fields to TRUE.
Syntax
Document_Validate (pWorkdoc as ISCBCdrWorkdoc, pValid as Boolean)
Parameter | Description |
---|---|
pWorkdoc | The current workdoc |
pValid | Parameter containing the current valid state of the workdoc. |
Sample Code
Private Sub Document_Validate(pWorkdoc as SCBCdrWorkdoc, pValid as Boolean)
Dim Number as string
Dim Name as string
'get fields name and number and make a database lookup
Number = pWorkdoc.Fields("Number")
Name = pWorkdoc.Fields("Name")
if LookupDBEntry(Name, Number) = FALSE then
'the Name/Number pair is NOT in the database set the document state to invalid
pValid = FALSE
'make both fields invalid and provide an error description
pWorkdoc.Fields("Number").Valid = FALSE
pWorkdoc.Fields("Number").ErrorDescription = "Not in database"
pWorkdoc.Fields("Name").Valid = FALSE
pWorkdoc.Fields("Name").ErrorDescription = "Not in database"
end if
End Sub