Generate Fancy Reports

Dear Friends,

You have difficulty in generating reports in Notes? Here is the code that will
take off your burden.

In this code I have referred a form named "Report form", which has a rich text
field called "Report",
I have a SaveOptions field it can be of any type. The Data to generate the
report is got from "Report view"

This code is put in an action button.

If you have any questions please send me a mail at skanth@parker.com

With regards
Sashi

Sub Click(Source As Button)
Dim ws As New notesuiworkspace
Dim UIDoc As NotesUiDocument
Dim session As New NotesSession
Dim db As NotesDatabase
Dim Doc As NotesDocument
Dim Doc1 As NotesDocument
Dim view As NotesView
Dim richStyle As NotesRichTextStyle

Set UIDoc = ws.currentdocument
Set db = session.CurrentDatabase
Set view = db.GetView( "Report View" ) 'View which you want to present in
the report

'i had to do this block to make it R5 compatible
Set Doc1 = UIDoc.document
Doc1.form ="Report Form"
Doc1.saveoptions ="1"
Call Doc1.save (True,True)
Doc1.saveOptions="0"
Call UIDoc.refresh
Call UIDoc.Close
Set UIDoc =ws.editdocument( True, Doc1)
Set Doc1 = UIDoc.document
'ends
Set richStyle = session.CreateRichTextStyle
Dim rtitem As Variant
Set rtitem = Doc1.GetFirstItem( "Report" ) ' Report is a rich text field

richStyle.FontSize = 9
Call rtitem.AppendStyle(richStyle)

Set Doc = View.GetFirstDocument

While Not ( doc Is Nothing )
' Use Chr(9) for Tab and Chr(10) for new line

rtitem.APPENDTEXT(Chr(10)+"_____________________________________________________
______________________________________ "_
+"
"+Chr(10)+Chr(10)+Doc.Field1(0)+Chr(9)+Doc.Field2(0)+Chr(9)+Doc.Field3(0)+Chr(9)
+Doc.Field4(0)+Chr(10))
' Setting the font type
richStyle.Bold = True
Call rtitem.AppendStyle(richStyle)
rtitem.APPENDTEXT( "Remarks: ") ' add labels in your report

richStyle.Bold = False
Call rtitem.AppendStyle(richStyle)
rtitem.APPENDTEXT(Doc.Feild5(0))

Set Doc = View.GetNextDocument(doc)

Wend
' Add a line at the end of the report

rtitem.APPENDTEXT(Chr(10)+"_____________________________________________________
______________________________________ ")

Doc1.form ="Report Form" ' name of the report form
Doc1.saveoptions ="1" 'must have a SaveOptions field on the report form
Call Doc1.save( True,True)
Doc1.saveOptions="0"

Call UIDoc.Close
Set UIDoc =ws.editdocument(True, Doc1)
Call UIDoc.refresh
End Sub
This was first published in November 2000

Dig deeper on Lotus Notes Domino Administration Tools

0 comments

Oldest 

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:

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.uk

Close