I’m trying to build a search form that has a text field for user input to create a query. The user should enter a town name and this will then look at the field (Line5) containing this data - or at least that’s what I was thinking it did. Example - user enters TownA and results are returned with all docs that have TownA in the specified field. So far so good. but if the user enters ‘or’ in the text field i.e. TownA or TownB, the results return not only TownA and TownB records for the specified field but also any records that have TownA in another field such as the Company Name e.g. TownA Engineering. I haven’t come across anything in any of my searches that can explain this. Can anybody shed any light? Here is the code -
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim view2 As NotesView
Dim vc As NotesViewEntryCollection
Dim v2 As NotesViewEntryCollection
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set view2 = db.GetView("searchresults")
Set v2 = view2.AllEntries
Call v2.RemoveAllFromFolder("searchresults")
Dim ws As New NotesUIWorkspace
Dim uidb As NotesUIDatabase
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
query$=doc.Query(0)
querysec1$=doc.Sector1(0)
querysec2$=doc.Sector2(0)
Messagebox query$
Messagebox querysec1$
Messagebox querysec2$
Set view = db.GetView("SearchBA3")
Set vc = view.AllEntries
If query$ <> "" Then
Call vc.FTSearch( ("FIELD Line5 CONTAINS " & query$ ), 0)
End If
If querysec1$ <> "" Then
Call vc.FTSearch( ("FIELD Sector1 CONTAINS " & querysec1$ ), 0)
End If
If querysec2$ <> "" Then
Call vc.FTSearch( ("FIELD Sector2 CONTAINS " & querysec2$ ), 0)
End If
Call vc.PutAllInfolder("searchresults")
If vc.Count > 0 Then
Set uidb = ws.CurrentDatabase
Call uidb.OpenView("searchresults", , True)
Call uiDoc.FieldSetText("SaveOptions", "0")
Call uidoc.Close(True)
Else
Messagebox "No results found"
End If
End Sub