Darn Reoports

This is how I solved most of the reporting in my notes applications.

The output of this routine is a document ready for printing, which is by itself
a collection of documents.

This is the internal working of the process...

you will need 2 forms for this routine to work
1. A page layout (Title/ Subtitle/ Date/ Header/ Footer/ Body[rtfield])
2. A document Template (e.g. status/ assigned to etc...)

The idea is the following many 'document templates' will be rendered on the
print layout, which eventually will be printed.

The specific code presented here, builds the collection as well based on some
user selections (the click is triggered from a dialog box).
The original form is called 'Main', the page layout is called 'PrintPreview',
the form for rendering each document for printing is called 'PrintItem'. The
real code discussed here is toward the end (last 15 lines or so).

Sub Click(Source As Button)
'Written by Riccardo Coen
'distributable freely, just keep these lines comments in.

Dim previewUidoc As notesuidocument
Dim uidoc As notesuidocument
Dim ws As New notesuiworkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim docSource As NotesDocument
Dim docPrintPreview As NotesDocument
Dim rtitem As NotesRichTextItem
Dim lookupView As notesview
Dim lookupCollection As notesdocumentcollection
Dim subject As String
Dim success As Variant
Dim coll As notesdocumentcollection
Dim i As Double
Dim formula As String
Dim parties As String
Dim status As String
Dim subtitle As String
Dim item As NotesItem
Dim cutOffDate As NotesDateTime
Dim authorsItem As notesitem
'...set value of doc...

Set uidoc = ws.currentdocument
Set db = session.CurrentDatabase
'build the list of document that we will need to print

formula = "Form = 'Main' "
parties = uidoc.fieldgettext("Parties")
status = uidoc.fieldgettext("Status")
tmp = ""

If parties <> "Any" Then
formula = formula & " & (! (@isnotmember( @explode('" & parties &
"'); Leader:Follower ))) "
End If

If status <> "All" Then
If status = "Outstanding" Or status = "Assigned" Then
tmp = "Outstanding; Assigned"
formula = formula & " & (! (@isnotmember( @explode('" & tmp &
"'); Status )))"
Elseif status = "Overdue" Then
formula = formula & "& duedays < 0 "
formula = formula & "& Status = '"& status &"'"
End If
End If

Set cutOffDate = New NotesDateTime( uidoc.fieldgettext("Created") )

Set coll = db.search(formula, cutOffDate, 0)

' STEP 2

If coll.count>0 Then

'Create the document on which we will be adding output "the print preview"
Set docPrintPreview = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( docPrintPreview, "Body" )
docPrintPreview.Form = "PrintPreview"

'lookup subject either on the view or... through a search
docPrintPreview.subject = APPLONGNAME '-> defined in script library
'and set the subtitle if required

subTitle = Status + " Action Points" + Chr$(10)
tmp = ""
If Parties <> "Any" Then

'get rid of the ; in the leaders list
tmp = Evaluate( "@replacesubstring('"+ Parties +"'; ';' ;
subtitle = subTitle + "Assigned to: "+ tmp(0) + "."
End If
docPrintPreview.subTitle = subtitle
'the next step is needed since the user will need to delete this document once
he's printed it.
Set authorsItem = docPrintPreview.ReplaceItemValue(
"PrintPreview_Authors", session.UserName )
authorsItem.IsAuthors = True

'======The following variables are using for sorting purposes (THIS
Redim sortKey(coll.count) As Variant
Redim docIds(coll.count) As String
For i=1To coll.count
Set docSource = coll.getnthdocument(i)
sortKey(i) = docSource.agendaitem(0)
Call qsortdocs(sortKey, docIds, 0, coll.count)
'======Up to here

'Now populate the body of the print preview
For i = 1 To coll.c

This was first published in November 2000

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.