Examples: Accessing a form

  1. This example displays the properties of a form.
    Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim form As NotesForm
      Set db = session.CurrentDatabase
      Set form = db.GetForm(Inputbox("Name of form?"))
      Messagebox "Name: " & form.Name
      If Not Isempty(form.Aliases) Then
        Forall aliaz In form.Aliases
          Messagebox "Alias: " & aliaz
        End Forall
      End If
      If form.IsSubForm Then Messagebox "Is a subform"
      If form.ProtectReaders Then
        Messagebox "Readers are protected"
      Else
        Messagebox "Readers are not protected"
      End If
      If Isempty(form.Readers) Then
        Messagebox "No readers"
      Else
        Forall reader In form.Readers
          Messagebox "Reader: " & reader
        End Forall
      End If
      If Isempty(form.FormUsers) Then
        Messagebox "No form users"
      Else
        Forall formuser In form.FormUsers
          Messagebox "Form user: " & formuser
        End Forall
      End If
      Forall field In form.Fields
        Messagebox "Field: " & field
      End Forall
    End Sub
  2. This example checks for the existence of a form by comparing a specified name with the names of the forms in the current database.
    Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Set db = session.CurrentDatabase
      formNameIn = Lcase(Inputbox("Name of form?"))
      Forall form In db.Forms
        If Lcase(form.Name) = formNameIn Then
          Messagebox _
          "The form """ & formNameIn & """ exists"
          Exit Sub
        End If
      End Forall
      Messagebox _
      "The form """ & formNameIn & """ does not exist"
    End Sub