アプリケーションの設計


例:イベントのスクリプトまたは式を作成する
ユーザーが文書を閉じた時にメッセージを表示する

フォームに対する次の QueryClose イベントスクリプトを使用すると、編集していた文書を閉じたときにメッセージが表示されます。

Sub QueryClose(Source As Notesuidocument,ContinueAsVariant
  Dim workspace As New NotesUIWorkspace
  Dim doc as NotesUIDocument
  Set doc = workspace.CurrentDocument
  If doc.EditMode Then
     Messagebox("Call Pat at x-314 if you have any questions.")
  End If
End Sub

フィールドを自動的に埋める

フィールドの Entering イベントに次のスクリプトを記述すると、[FirstName] フィールドとスペースと [LastName] フィールドを連結して、[FullName] フィールドを埋めることができます。

Sub Entering(Source As Field)
  Dim workspace As New NotesUIWorkspace
  Set doc = workspace.CurrentDocument
  firstName = doc.FieldGetText("FirstName")
  lastName = doc.FieldGetText("LastName")
  fullName = firstName & " " & lastName
  Call doc.FieldSetText("FullName", fullName)
End Sub

フィールドへの入力を要求する

フィールドの Exiting イベントに次のスクリプトを記述すると、ユーザーが [FirstName] フィールドを入力した後に、[LastName] フィールドを入力するように要求するメッセージが表示されます。

Sub Exiting
  Dim W As New NotesUIWorkspace
  Dim UIDoc As NotesUIDocument
  Set UIDoc = W.CurrentDocument
  If (UIDoc.FieldGetText ("LastName") <> "") Then
    UIDoc.GotoField "FirstName"
  Else
    UIDoc.GotoField "LastName"
   Messagebox "You must enter the person's last name.", 0, "ERROR"
 End If
End Sub

関連項目