Examples: FTDomainSearch method

The following code, when placed in a button on a search form within a directory catalog database, searches the directory for the specified query string, and returns all results.

Sub Click(Source As Button)
    Dim s As New NotesSession
    Dim db As NotesDatabase
    Dim w As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim doc as NotesDocument
    Dim quer As String
    Dim srdoc as NotesDocument
    
    
    Set db=s.CurrentDatabase
    Set uidoc = w.currentdocument
    uidoc.refresh
    Set doc=uidoc.Document
    
    quer=doc.query(0)
    
    On Error Resume Next     
    If db.isopen Then
        If Err <> 0 Then
            Messagebox STR_DBOPEN_ERROR, 0 , STR_ERROR
            Err = 0
            Exit Sub
        End If
        
        Set srdoc = db.ftdomainsearch(quer, 0)
        
        If Err <> 0 Then
            Messagebox STR_NDF , 0 , STR_LOTUS_NOTES
            Err=0
            Exit Sub
        End If
        
        srdoc.Form="SearchResults"
        Call w.EditDocument(False, srdoc, True)
    End If
End Sub