Hi,I have a program which will compare the total amount of all documents by key,I tried using GetAllEntriesbykey and Getalldocumentsbykey, but the result are different. The total amount is equal for using getalldocumentsbykey, but is not equal when I am using Getallentriesbykey, I also using messagebox to display the result, they are actually are equal. but how come the result is different for the two Notes objects?
Thanks a lot for any help.
this is the codes using Getalldocumentsbykey:
Dim session As New NotesSession
Dim db As notesdatabase
Dim view As notesview
Dim viewEntry As notesviewentry
Dim doc As notesdocument
Dim totalCR As Double
Dim totalDR As Double
Dim viewEntryColl As notesviewentrycollection
Dim selectedInvoiceFolderNV As notesview
Set db = session.CurrentDatabase
Set view = db.GetView( "JVLineDisplay" )
Set viewEntryColl = view.GetAllEntriesByKey("CB000983")
totalCR = Cdbl(0)
totalDR = Cdbl(0)
Set viewEntry = viewEntryColl.getfirstentry
While Not viewEntry Is Nothing
Set doc = viewEntry.document
If Instr(doc.JV_DBCR(0), "Credit") Then
totalCR = totalCR + doc.jamount(0)
Else
totalDR = totalDR + doc.jamount(0)
End If
Set viewEntry = viewEntryColl.getnextentry(viewEntry)
Wend
If totalDR = totalCR Then
Messagebox "They are equal"
Messagebox "totalCR:" + Cstr(totalCR) + "totalDR:" + Cstr(totalDR)
Else
Messagebox "they are not equal"
Messagebox "totalCR:" + Cstr(totalCR) + "totalDR:" +Cstr(totalDR)
End If
Thanks a lot for all of your help.I have tried to set the TotalDR and TotalCR to zero, it is still not working.
The reason is that the codes which using the ViewEntrycollection are running on the production now, and it works for a long time, but today we found only case it is not working, I debug the codes and creating a agent to test it, I found the getalldocumentsbykey is working for this case,we can not replace it only for this case, probably it is not working for other cases. I must figure out why.
A major difference appeare when you use multi-valued fields.
IN THEORY…if you create a view where th first column is based on a multi-valued date fields and set this column to show each value in a specifique row. A GetAllDocumentByKey order where key is a date, will return all document.
A GetAllEntriesByKey will return only row according to the date passed as argument.
IN THEORY… Because this is not working everytime as expected.