RE: Do Until Loop using NotesViewEntryCollection Not Working Marilyn Laudadio 7.Dec.05 12:05 AM a Web browser Domino Designer -- LotusScript Release 5Windows XP
Couple of things...some typo's here and here that I've noted below.
You had remarked out the First DO loop, so if vEntry was nothing then count is nothing. When you instantiate mArray(count-1) then you will throw an error.
Also, not sure why after the mArray(Count) = vc.Count you add the do-loop with the vc.entries, since the vc collection will return the document count, right?
I find it easier to align two arrays if I use a for/next loop to assign values. Also, you instantiated the mArray as string, so I converted the numeric counts to strings..if you want them to line up in a report, you might want to format(vc.count, "000")
Here is revised code - untested:
------------------------------------
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim viewTotal As NotesView
Dim vc As NotesViewEntryCollection
Dim VCTotal As NotesViewEntryCollection 'TYPO HERE: DimVCTotal
Dim report As NotesDocument 'TYPO HERE: Notes Document
Dim dt As New NotesDateTime("")
Set db = s.CurrentDatabase
Set report = db.CreateDocument
report.Form = "Monthly Report NEW"
Dim mArray() As String
Dim gArray() As String
Dim count As Long
Count = 0
Redim mArray(count)
Redim gArray(count)
'get view
Set view = db.GetView("view")
'create view navigator
Dim vNav As NotesViewNavigator
Set vNav = view.CreateViewNav
'get first entry of navigator
Dim vEntry As NotesViewEntry
Set vEntry = vNav.GetFirst
'get all categories in the view navigator
Do Until vEntry Is Nothing '<<TYPO HERE - DO IS REMARKED OUT
gArray(count) = vEntry.ColumnValues(0)
count = count + 1
Redim Preserve gArray(count)
Set vEntry = vNav.GetNextCategory(vEntry)
Loop
'use the size of the gArray to redimension the mArray to hold doc counts
'ml: If vEntry was nothing then count is 0 so you have to trap for this
If count-1>=0 Then
Redim mArray(count - 1)
'Also might want to trim the last gArray entry since you're searching for it
If gArray(Count)="" Then
Redim Preserve gArray(Count-1)
End If
Else
Redim mArray(0)
End If
%REM
'reset count variable to use below
'count = 0
'**********
%END REM
'get number of docs for each team
'ML: might be easier to align the arrays if you use the for next
For k = Lbound(gArray) To Ubound(gArray)
If gArray(k)<>"" Then
Set vc = view.GetAllEntriesByKey(gArray(k), True)
mArray(k) = Cstr(vc.Count)
Else
mArray(k) = "0"
End If
Next
%REM
Forall team In gArray
'get view entry collection for each team
Set vc = view.GetAllEntriesByKey(team, True)
'set initial count to collection count
'<<<<<<<<<<<< mArray(count) = vc.Count >>>>>>>>>>>>>>
Do Until vEntry Is Nothing
Set vEntry = vc.GetFirstEntry()
Set vEntry = vc.GetNextEntry(vEntry)
Loop
count = count + 1
End Forall