例: OnSubmit event

  1. 次の Onsubmit イベントは、[Title] フィールドが空のとき、保存操作を中止し、[Title] フィールドに挿入点に移動します。
    Sub Onsubmit(Source As Notesuidocument, _
    Continue As Variant)
      If Source.FieldGetText("Title") = "" Then
        Messagebox "You must enter a title",, "No title"
        Call Source.GotoField("Title")
        Continue = False
      End If
    End Sub
  2. 次の OnSubmit イベントは、現在の日付と [DueDate] フィールドの日付の差異に基づいて、[ProjectStatus] フィールドを更新します。
    Sub Onsubmit(Source As Notesuidocument, _
    Continue As Variant)
      Dim todayDT As NotesDateTime
      Dim dueDT As NotesDateTime
      Dim daysLeft As Long
      Dim status As String
      Call Source.Refresh
      Set todayDT = New NotesDateTime("Today")
      Set dueDT = New NotesDateTime _
      (Source.FieldGetText("DueDate"))
      daysLeft = dueDT.TimeDifference(todayDT) / 86400
      Select Case daysLeft
      Case 1, 2, 3
        status = "Urgent"
      Case 4, 5, 6
        status = "Hurry up"
      Case Else
        status = "No worries"
      End Select
      Call Source.FieldSetText("ProjectStatus", status)
    End Sub