Question : Looping through views problem in Lotus Notes

I have two views, in the first I loop through and filter out any staff members.  The remaining personel are paid according to invoices submitted.  All invoices are viewed in a second view together with the name of the person who submitted them.  I want to loop though the first view and at each name not filtered out, loop through the second view and just get the invoices that that person has submitted, filtering out all the others.  I thought I would be able to use an If statement to trap the name in the InvName field, but it doesn't work.
How can I best do this?

Do Until doc Is Nothing                  
      Forall entry In doc.ContractorType                        
            contractorTypeStr =    entry             
            If contractorTypeStr = "STAFF" Goto continue                  
            Forall names In doc.NotesName
                  nameStr = names                        
                  Do Until doc2 Is Nothing
                        Forall invTotals In doc2.InvTot
                              'If  doc2.InvName  = nameStr Then
                                    approvedInvTotal =  invTotals
                                    'Print(approvedInvTotal)
                              'End If                                    
                        End Forall
                        Set doc2 = v2.GetNextDocument(doc2)      
                  Loop
                  Forall contractTypes In doc.ContractType                        
                        contractTypeStr =    contractTypes       
                        If contractTypeStr = "CLAS" Then
                              Goto continue
                        End If
                  End Forall                        
            End Forall                  
continue:      
      End Forall            
      Set doc = v.GetNextDocument(doc)                  
Loop      

Answer : Looping through views problem in Lotus Notes

Yes, you have the Getfirst's but probably not at the right place. Because once you finished looping through the second view, you will stay at the end, forever.

Probably you need to set up your logic differently, like this (pseudo-code):

    doc.getfirstdoc
    do until doc is nothing
        get name
        doc2= view2.getdocbykey(name,true)
        do until doc2 is nothing
            if doc2.name<>name then exit do
            ...handle the document
            doc2= nextdoc(doc2)
        loop
        doc= nextdoc(doc)
    loop

And you may compare strings as you did. Btw, you don't need to use both "entry" and "contractorTypeStr", just "entry" will do. Or use
    Forall contractorTypeStr in doc.ContractorType
Random Solutions  
 
programming4us programming4us