Strange results when using GetAllEntriesbyKey and Getalldocumentsbykey

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.

  1. 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

Subject: I M not sure

Cause I haven’t got designer open with the help.

But I think it could be a problem of index cause I think that the entries work like a collection…

But I don’t use them often and I m not sur about it.

Subject: RE: I M not sure

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.

Anyway, thanks a lot for your help.

Subject: Difference between Entry and Document

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.

Subject: strange results when using GetAllEntriesbyKey and Getalldocumentsbykey

you may want to try to first set totalCR and totalDR equal to 0, or maybe that step is just missing from above.

ex:

Dim totalCR as Cdbl(0)

Dim totalDR as Cdbl(0)

totalCR = 0

totalDR = 0

Then do the WhileNot

Just a quick question: If you have a method that works, (getalldocsbyKey), then why not just run with it and forget the other method? Just curious