Subject: View : “Show multiple Categories”
It sounds like you are trying to build a small query engine. I did this awhile ago, using two forms both with their SaveOptions set to 0. My query form consists of the ability to set beginning and ending date creation parameters, along with another layer of filtering for existing models,(the primary field I am using for sorting documents in all of the views). The existing models are a dynamic list combobox built from a view with @unique applied to the field via a categorized column, then accessed via @dbcolumn in the field’s choice selection formula. Once I populate the field values mentioned, I click the “Run Query” button…the next form has a rich text field. The button creates a back-end document, a notes rich text item, and an integer to count the number of documents matching the search criteria. These are the same elements that the second form contains. Anyway it is all wrapped in a frameset, so the result will display contained in the lower portion of the window. HTH.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim newsletter As NotesNewsletter
Dim doc As NotesDocument
Dim parseDoc As NotesDocument
Dim nextDoc As NotesDocument
Dim resultDoc As NotesDocument
Dim uidoc As NotesUIDocument
Dim nuidCurDoc As NotesUIDocument
Dim v As NotesView
Dim entry As NotesViewEntry
Dim entrytwo As NotesViewEntry
Dim vc As NotesViewEntryCollection
Dim nav As NotesViewNavigator
Dim collection As NotesDocumentCollection
Dim count As Integer
Dim total As Integer
Dim inx As Integer
Dim temp As Variant
Dim getSpecModel As String
Dim displayBeg As String
Dim displayEnd As String
Dim rtitem As NotesRichTextItem
Dim begItem As NotesItem
Dim endItem As NotesItem
Dim item As NotesItem
Dim getDocCreated As NotesItem
Dim beginDateTime As NotesDateTime
Dim endDateTime As NotesDateTime
Dim compareDocCreated As NotesDateTime
'…set value of doc…
count = 0
total = 0
Set db = session.CurrentDatabase
Set v = db.GetView("(Model Sorts)")
Set uidoc = workspace.CurrentDocument
Set doc = workspace.CurrentDocument.Document
Set resultDoc = New NotesDocument(db)
Set begItem = doc.GetFirstItem( "beginningDate" )
Set beginDateTime = begItem.DateTimeValue
Set endItem = doc.GetFirstItem( "endingDate" )
Set endDateTime = endItem.DateTimeValue
displayBeg = Cstr(doc.beginningDate(0))
displayEnd = Cstr(doc.endingDate(0))
'if timedifference parameter to the left is greater than parameter to the right
'being greater than zero will flag it as such
If beginDateTime.TimeDifference(endDateTime) > 0 Then
Messagebox "The end time that you entered is less than the begin time. Please revise.", 16, "Error"
Exit Sub
End If
'assign the displayForm
resultDoc.Form = "DateCollection"
Set rtitem = resultDoc.createRichTextItem("allLinks")
'establish connection to the first document in the sorted view...get a count on the total collection before date filter is applied
'retrieve the model requested in the ui form
getSpecModel = doc.parseModelNum(0)
Set vc = v.GetAllEntriesByKey(getSpecModel)
If vc Is Nothing Then
Messagebox "No quotations exist referencing this item. It may have been deleted", 0 + 16, "Quotation does not exist"
Exit Sub
End If
inx = 1
'since these documents are categorized using a multi-value field, using the NotesViewEntryCollection classes to iterate through the docs
'generates a item has been removed error. We must use the NotesViewNavigator to perform these tasks. To control iteration,
'we will use the total count from the NotesViewEntryCollection object as the sentinel value
Set nav = v.CreateViewNavFromCategory(getSpecModel)
Set entry = nav.GetNth(inx)
If Not entry Is Nothing Then
Set parseDoc = entry.Document
If parseDoc Is Nothing Then
Messagebox "This quotation does not exist", 0 + 16, "Quotation does not exist"
Exit Sub
Else
Set getDocCreated = parseDoc.GetFirstItem("dateCreated")
Set compareDocCreated = getDocCreated.DateTimeValue
Call rtitem.AppendText( "This is a list of all quotations containing model " & getSpecModel & " found between dates : " & displayBeg & " - " & displayEnd)
Call rtitem.AddNewLine( 1 )
Call rtitem.AddNewLine( 1 )
If (compareDocCreated.TimeDifference(beginDateTime) >= 0) And (compareDocCreated.TimeDifference(endDateTime) < 0) Then
Call rtitem.AppendText( "Document Link: " )
Call rtitem.AppendDocLink( parseDoc, db.Title )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Document Information: " )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Account: " )
Call rtitem.AppendText( parseDoc.Account( 0 ) )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Contact Name: " )
Call rtitem.AppendText( parseDoc.Contact( 0 ) )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Date Created: " )
Call rtitem.AppendText( parseDoc.dateCreated( 0 ) )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Confidence Level: " )
Call rtitem.AppendText( parseDoc.ConfidenceLevel( 0 ) & " %")
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Projected Order Date: " )
Call rtitem.AppendText( parseDoc.ProjOrderDate( 0 ) )
Call rtitem.AddNewLine( 1 )
Call rtitem.AddNewLine( 1 )
total = total + 1
Call resultDoc.Save( False, True )
End If
inx = inx + 1
End If
End If
Set entryTwo = nav.GetNth(inx)
If Not (entryTwo Is Nothing)Then
While inx <= vc.Count
Set nextDoc = entryTwo.Document
Set getDocCreated = nextDoc.GetFirstItem("dateCreated")
Set compareDocCreated = getDocCreated.DateTimeValue
If (compareDocCreated.TimeDifference(beginDateTime) >= 0) And (compareDocCreated.TimeDifference(endDateTime) < 0) Then
Call rtitem.AppendText( "Document Link: " )
Call rtitem.AppendDocLink( nextDoc, db.Title )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Document Information: " )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Account: " )
Call rtitem.AppendText( nextDoc.Account( 0 ) )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Contact Name: " )
Call rtitem.AppendText( nextDoc.Contact( 0 ) )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Date Created: " )
Call rtitem.AppendText( nextDoc.dateCreated( 0 ) )
Call rtitem.AddNewLine( 1 )
%REM
Call rtitem.AppendText( "Confidence Level: " )
Call rtitem.AppendText( parseDoc.GetItemValue("ConfidenceLevel") & " %")
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( "Projected Order Date: " )
Call rtitem.AppendText( parseDoc.ProjWinDate( 0 ) )
Call rtitem.AddNewLine( 1 )
%ENDREM
Call rtitem.AddNewLine( 1 )
total = total + 1
Call resultDoc.Save( False, True )
End If
inx = inx + 1
Set entryTwo = nav.GetNth(inx)
Wend
End If
Call workspace.SetTargetFrame("bottom")
doc.saveoptions = "0"
resultDoc.Total = total
Call uidoc.Close
Call workspace.EditDocument(True, resultDoc, False)
End Sub