Search By View Entry

Hi,

i am using the following code , to search by the value of “Search” field.

Sub Click(Source As Button)

Dim db As NotesDatabase

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument 

Dim uidb As NotesUIDatabase



Set db = session.CurrentDatabase

Set uidoc = ws.CurrentDocument

Set uidb = ws.CurrentDatabase



Dim SearchView As NotesView

Dim SearchDoc As NotesDocument

Dim Searchentry As NotesViewEntry

Dim key As String

Dim v As Variant 



Set SearchView = db.GetView("SearchProjects")	



If uidoc.FieldGetText("Search") ="" Then

	Messagebox "Please enter the Project Number"

	Call uidoc.GotoField ("Search")

	Exit Sub

End If







key = uidoc.FieldGetText("Search")





Set Searchentry = SearchView.GetEntryByKey (key)



If Not (Searchentry Is Nothing )	Then	

	Set SearchDoc = Searchentry.Document

	Call ws.SetTargetFrame("NotesView")

	Call ws.EditDocument(False,SearchDoc)

	Call ws.ViewRefresh

Else

	Messagebox "Project number not found." +"Please enter the correct project number." +"Project number must be without '#'"

	Call uidoc.GotoField ("Search")

	Exit Sub

End If

End Sub

I am facing a problem. Lets say there are 3 projects with nos. 4809,4810,4812.

When I am entering them individually in the “Search” field it works fine. But If I input 48 only, it opens 4809. Why? I want that it should give error saying that the Project no. is incorrect.

Pls help.

Subject: Search By View Entry

Hi Sandip,

Use

Set Searchentry = SearchView.GetEntryByKey (key, true)

if you do not specify true, a partial match succeeds (in your case 48)

Regards,

René

Subject: RE: Search By View Entry

Hi Rene,

Thanks it worked.