Sample VB script code : Settings Default Values for Template Fields to be Used in FormDocs Filler
From Support
Contents |
Utilizing the "FormDocs Automation Basic Editor" (AKA Forms Scripting)
Step 1: Open the Form Template
Launch the FormDocs Designer. Open the desired FormDocs Form Template or create a new form.
Step 2: Open the "FormDocs Automation Basic Editor"
Select Tools > Forms Automation Basic Editor from the menu bar. This will open up a new window:
The FormDocs Automation Basic Editor can be opened via the file menu: Tools > Forms Automation Basic Editor NOTE: You can also open the Forms Automation Basic Editor using Alt + F11
Step 3: Locating the Appropriate Place to Write the Script
In this new window, locate the drop-down menu labeled "Automate this Object:" in the upper-left region and select "RecordSet" from the drop-down menu (3rd option).
Now locate the drop-down menu labeled "Program this event:" in the upper-right region and select "Current" from the drop-down menu.
NOTE: These options differ from most of our other scripting samples
Step 4: Where to Write the Script
In the main window (no label), you will need to write your script after the line starting with "Private Sub...." and before the line that reads "End Sub".
Scripting Within Your Form
Testing for a New Record Set
When you first open a Form Template within the FormDocs Filler application, 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. This Record Set is what we want to manipulate.
However, we want to make sure that we only manipulate the value when the template first opens. We do not want to keep resetting the value of the field on the end-user.
In order to handle this process properly, we need to test for a new Record Set. The RecordSet objects within the FormDocs Forms Automation Basic Editor have a method called .NewRecord that can indicate whether a new Record Set is being created. It returns a Boolean value which means that it returns TRUE if a new Record Set is being created and FALSE if it is not.
We need to use this new option within an IF condition:
If ThisForm.RecordSet.NewRecord Then End If
Setting the Default Values
Now that we have our code to test for a new Record Set in place, we need to add code assign our default Field values. This can be done by simply assigning a new value to the Field's .value. The following code sample needs to go within the IF condition that we setup in the previous step.
NOTE: For this example, the field name will be called "FIELD_NAME". Please change this to match your own Field name.
ThisForm.Fields("FIELD_NAME").value = "Default Value"
NOTE: Repeat the above code for each and every Field to which you desire to assign a default value.
Final Code Sample
After putting the last two steps together, we should now have a script looks similar to the following:
'The following code will assign a default value to a field when it is opened within the FormDocs Filler application. If ThisForm.RecordSet.NewRecord Then ThisForm.Fields("FIELD_NAME").value = "Default Value" 'Repeat the above code for each Field to which you desire to assign a default value. End If

