The following shows you how to set default values for template fields to be used in FormDocs filler and provides sample VB script code.

Using Forms Scripting

  1. In the FormDocs Designer, open a FormDocs form template or create a new form.
  2. In the menu, choose Tools > Forms Automation Basic Editor.

    Note: You can also open the FormDocs Automation Basic Editor by pressing Alt + F11.

    The FormDocs Automation Basic Editor opens.

  3. In Automate this Object, choose RecordSet.
  4. In Program this event, choose Current.

    Note: These options differ from most other scripting samples.

  5. In the main window,  write your script after the line Private Sub and before the line End Sub.

Testing for a New Record Set

When you first open a form template in FormDocs, it creates a new set of values for each of the field objects in the form template. This is known as creating a new record set. The scripting will manipulate this record set.
However, you need to make sure that you only manipulate the value when the template first opens, so that it does not keep resetting the value of the field for the end-user.
To handle this process properly, test for a new record set. The RecordSet objects in FormDocs Forms Automation Basic Editor have a method called .NewRecord to indicate whether a new record set is being created. .NewRecord returns a Boolean value: TRUE if a new record set is created, and FALSE if it is not.
Use this option in an IF condition:
If ThisForm.RecordSet.NewRecord ThenEnd If

Setting the Default Values

Once the test for a new record set is in place, add code to assign the default field values. To do this, assign the field a new .value. This code goes inside the IF condition from the previous step.
Use the following syntax, where FIELD_NAME is the field name:
ThisForm.Fields("FIELD_NAME").value = "Default Value"
Repeat this code for each field to assign a default value.

Final Code Sample

The final code for your script should look something like this:
'The following code will assign a default value to a field 
'when it is opened within FormDocs Filler.
If ThisForm.RecordSet.NewRecord Then

ThisForm.Fields("FIELD_NAME").value = "Default Value"
'Repeat the above code for each field to assign a default value.

End If

Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: December 10, 2016