Document value not getting set in script

Hi There,

I don’t know why the doc1 is not getting set in following code.

Declarations

Dim s As NotesSession

Dim db As NotesDatabase

Sub Initialize

Dim ns As New NotesSession

Set db = ns.Currentdatabase	

Dim view As NotesView

Dim doc As NotesDocument

Set view = db.GetView( "lkupemail" )



Set doc = view.GetFirstDocument

While Not ( doc Is Nothing )

	oldprod = doc.Product(0)

	emailcontent = doc.EmailText(0)

	

	If (doc.HasItem ("SendEmail") And doc.SendEmail(0) = "No") Then			

		Call SendMail1(doc)

	End If		

	Set doc = view.GetNextDocument( doc )

Wend

End Sub

Sub SendMail1 ( req As NotesDocument )

Dim view1 As NotesView

Dim dc As NotesDocumentCollection

Dim vc As NotesViewEntryCollection

Dim doc1 As NotesDocument

Set view1 = db.GetView("lkupcompany")	

Dim j, j1 As Integer

Set vc = view1.AllEntries ' This shows me total 8 documents in that view. First column is ASC/Not Categorized

query$ = req.product(0)

j = view1.FTSearch(query$, 0 )	' This shows me proper counts. Finds proper number of documents.

j1 = vc.Count ' This shows me proper counts

If j > 0 Then

	Set doc1 = view1.GetFirstDocument() ' Here the doc1 is not getting set. Any idea why?

	While Not (doc1 Is Nothing)

	.

	.

	.

	.

	Set doc1 = view1.GetNextDocument(doc1)

	Wend		

End If

End Sub

Thanks

MS

Subject: Sort view1 or try…

…using getNthEntry()