CreateLink

<< Click to Display Table of Contents >>

 

CreateLink

CreateLink(Property, Source, [BindType])

This method allows creating a Link with an object's property. In case of success, this method returns the object created. Otherwise, a script error occurs and this method returns Nothing. This method contains the parameters Property, which specifies the name of the property to which this Link is created, Source, which specifies the name of Link's source object, and BindType, which is optional and specifies the type of Link to create. If this parameter is omitted, then a Simple Link is created.

 

NOTE

Not all existing properties in an object allow creating Links. To check which properties allow this feature, go to the Links tab of an object's Properties Window. If the property is invalid for a Link, does not exist, or already contains a Link, then a script error occurs.

 

Available options for the BindType parameter

Option

Description

0 - Simple Link

In a Simple Link, its source value is copied to the property every time it changes

1 - Bidirectional Link

A Bidirectional Link works as a Simple Link, but when there is a variation in the property, its value is copied to the source, thus generating a two-direction Link

2 - Analog Link

An Analog Link specifies a conversion scale between the source variable and the property

3 - Digital Link

In a Digital Link, fixed or alternating values are set to the property, and these values are set according to whether the source is True or False

4 - Table Link

In a Table Link, users can specify conditions between the variables, the values, and the destination. On the table users can specify minimum and maximum values, as well as other configurations

5 - Reverse Link

A Reverse Link is a unidirectional Link from the property to the source

6 - Multisource Link

A Multisource Link is similar to a Table Link, except that each Link row allows retrieving its value from a different source

 

The next script contains an example of using this method.

Sub CommandButton1_Click()
  On Error Resume Next
  Dim bndType, bndValue
  bndType = 1 'Bidirectional Link
  Set bndValue = Screen.Item("Text1").Links.Item("Value")
  If bndValue Is Nothing Then
    MsgBox "Creating a Bidirectional Link"
    Set bndValue = Screen.Item("Text1").Links.CreateLink("Value", "Data.InternalTag1.Value", bndType)
  Else
    MsgBox "Text1 already contains a Link to " & bndValue.Source
  End If
End Sub

Was this page useful?