TeleForm features a whole host of validation options to help ensure that the data being exported is of the correct quality. This may be achieved by assisting the recognition engines or indeed by aiding the operators by flagging up or making automated decisions on incorrectly filled fields. TeleForm's built-in validation options include features such as numeric range checking, database lookups and dictionary matching. However, in some cases, more advanced validation checking is required. For these situations, did you know, it is relatively straightforward to add a small amount of VBA script to your forms...
Imagine a questionnaire which asks the participant whether they hold a driving license and, if they do, how long they have held it for. Here, two fields are provided. The first (Driving_License) simply asks the question, giving a "Yes" or "No" response, and the second (Driving_Duration) holds a numeric value for the number of years.

There are 4 possible scenarios with this combination of fields:
For the first two valid combinations, the data can be exported without any modification. However, the last two invalid combinations may require additional decisions by the TeleForm operator. In this example, VBA is written to set fields for review if there are problems. This means that if "Yes" is ticked and the Driving_Duration field is empty, we ensure the operator is stopped at the Driving_Duration field to double-check the recognition. Similarly, if "No" is ticked and a number of years are provided, the operator is stopped at the Driving_License field so that they can check the recognition on the choice field. Writing the 4 combinations in VBA gives the following script:
Private Sub Form_Evaluate()
If Driving_License.Choices(1).Value = True Then
'The Driving Licence field has been read as Yes, how about the duration?
If Trim(Driving_Duration.Text) = "" Then
'Problem: turn on Field Review flag for the Driving_Duration field
Driving_Duration.Status = Driving_Duration.Status Or tfFldReview
Else
'This is not a problem - the duration has been filled in
End If
Else
'The Driving Licence field is No (or blank), how about the duration?
If Trim(Driving_Duration.Text) = "" Then
'OK - the duration has not been filled in, which is good!
Else
'Problem: turn on Field Review flag for the Driving_License field
Driving_License.Status = Driving_License.Status Or tfFldReview
End If
End If
End Sub
Please note, the Green text is only commenting and is not required.
The VBA validation rules shown above are placed into the Form_Evaluate subroutine. This means that they are only run once for each form - when it is first evaluated. However, the field status modifications ensure that when there are problems, the operators are forced to review the problematic fields. The subject of VBA validations is a huge topic, and ePC can provide both training and full consultancy to improve your form data validation. Contact us for further information if you feel that VBA validation may be of use to your forms processing needs.
Note to editors: Please feel free to reproduce any of these documents in whole or part but we do request that you credit ePartner Consulting Ltd and put a link back to www.epc.co.uk on any web site that they are used on.