I have a piece of code wherein I am using Redim Preserve and when I output the results, the print seems to exponentially grow.I know the problem is with the Redim preserve. How do I clear my array such that I do not lose the pointer reference? I guess I would need to do it before the WEND. Any help is much appreciated.
Set db=session.currentdatabase
Set curdoc=session.documentcontext
Dim UserName As New NotesName(session.effectiveusername)
Dim newitem$, reslist$, ulist As Variant
g_serverName=curdoc.Server_Name(0)
g_strPath = curdoc.DBPath(0)
On Error Goto errhandler
g_strPath = curdoc.db(0)
RepTypeTX = ReplaceSubString(Strright(curdoc.Query_String(0),"&RepType="),"%20"," ")
strPath = db.Filepath
For k% = 1 To Len(strpath)
If Mid$(strpath,k%,1) = "\" Then
Mid$(strpath,k%,1) = "/"
End If
Next
Print |Content-Type:application/vnd.ms-excel|
Print |Content-Disposition:Attachment; filename="Report.xls"|
Set view = db.GetView ( "AllCertTemplates" )
Set ATview = db.GetView("xAllCertTemplates2")
Set viewNav = view.CreateViewNav
Set viewEntry = viewNav.GetFirst
Call ReportHeaderAndColumnTitles
While Not ( viewEntry Is Nothing )
If viewEntry.IsCategory = True Then
Dim keys As String
Dim templateList List As Boolean'
keys = Cstr(viewEntry.ColumnValues(0))
Set vcollection = ATview.GetAllEntriesByKey(keys, True)
If vcollection.count = 0 Then
Print {<p><center>}
Print {<table cellpadding=2 cellspacing=5 width=800>}
Print {<tr><td class="TblCell" align=center valign=center><font class="Title">Checklist Activity Template(s) Report</font></td></tr>}
Print {<tr><td align=center valign=center><font class="Title">No Documents Found</font></td></tr>}
Print {</table>}
Exit Sub
End If
Set Ventry = vcollection.GetFirstEntry()
Dim x As Integer
While Not (Ventry Is Nothing)
Set DocTwo = Ventry.Document
‘===========PROBLEM AREA============
Redim Preserve tmp1(0 To x) As String
tmp1(x) = DocTwo.ChecklistTemplate(0)
Set Ventry = vcollection.GetNextEntry(Ventry)
x = x+1
Wend
‘===========END PROBLEM AREA============
ulist = Unique(tmp1)
Forall u In ulist
reslist = reslist & Chr$(10) & u
Set ATEview = db.GetView("ActivityByTemplate3")
Set ATEcollection = ATEview.GetAllEntriesByKey(u, True)
Dim ATEentry As NotesViewEntry
Set ATEentry = ATEcollection.GetFirstEntry()
While Not(ATEentry Is Nothing)
Set accessdoc = ATEentry.Document
Call prt_Data(accessdoc, keys)
Set ATEentry = ATEcollection.GetNextEntry(ATEentry)
Wend
End Forall
Call EndHTML
End If
'**********************************************************
'HOW DO I reinitialise my array..I guess will have to be done here!
'**********************************************************
Set viewEntry = viewNav.GetNext ( viewEntry )
Wend