Adding a Control Example

Adding a Control Example

The following example uses the Add method to add a control to a form at run time.

To use this example, copy this sample code to the Script Editor of a form. Make sure that the form contains:

Dim Mycmd 
Sub CommandButton1_Click()
   
   Set Mycmd = Item.GetInspector.ModifiedFormPages("P.2").Controls.Add("Forms.CommandButton.1") ', CommandButton2, Visible)
  Mycmd.Left = 18
  Mycmd.Top = 150
  Mycmd.Width = 175
  Mycmd.Height = 20
  Mycmd.Caption = "This is fun." & Mycmd.Name
    
End Sub