We need to have at least two forms designed, a parent form allowing us to input data and load its child form, and the child form displaying the data passed from its parent if required. The following example shows how to use a Hotspot button to load a child form and pass data from a parent form's TextField to the child form's DynamicLabel.
Open Form Properties of the child form which we want to load and pass data to, and obtain its Form ID by looking at Form Properties Ã General.
Open the parent form and double-click the Hotspot in the Designer interface.
Obtain its Field Name and change Type to Script
Right click on the Hotspot and select "Events>AfterInkAdded to create an AfterInkAdded event in the Script Editor. The Editor will automatically open and the cursor will be inside the event.
Add the following code to this Hotspot function and this will preload the child form:
_component.RequestFormLoad(Child Forms FormID)
Then add the following code to search through all loaded forms until the child form is found, assign value from the parent forms TextField to the childs DynamicLabel and finally activate the child form:
For Each xLF As LoadedForm In _component.Forms If xLF.Form.FormID = "[Child Form's FormID]" Then xLF.Form.GetFormControlByName(“DynamicLabel“).Value = _TextField.Value _component.ActiveForm = xLF End If Next
By activating the child form, we will bring the child form in the front of the screen after Hotspot
An example of a fairly complex form using this method is attached.
- DuckPond (Sub-Forms).mfd - This is the main form used.
- The other forms are subforms that have been attached to the main DuckPond form.