Email:   
Home
In This Issue
EasyPrint
Click here for the RSS feed's XML code. This is not a browser URL.
PROGRAMMING POWER
How to create subforms that configure other subforms
By Chris Doig

Here's a scenario. You have written a marvelous subform called RevHistory that creates a full audit trail of all document changes, as seen in Figure A. Applications are endless, and the paranoid want you to use it everywhere.

FIGURE A

You're now the proud owner of this handy RevHistory subform. Click picture for a larger image.

To make RevHistory a general-purpose subform for your library, you create the RevHistory Setup subform. This subform goes on a tab on the database profile form and configures RevHistory for that database.

But there's a problem! For RevHistory to get the setup parameters from the RevHistory Setup subform, you must know the name of the database profile form. However, you can't hard-code the database profile form name because that would mean your subform would no longer be a general-purpose object.

How can you get information from the setup subform when you don't know the name of the database profile form?

The solution
The trick is to use an intermediate profile document. The RevHistory subform gets the name of the database profile form from this intermediate document and then opens the database profile. Here's how you do it.

On your RevHistory Setup subform you include the code to create the intermediate profile document automatically. The first time you save the database profile document that contains the RevHistory Setup subform, your code creates the intermediate profile document with a known form name. (Although it has a form name, this intermediate document does not actually require a form.)

When you save a document with the RevHistory subform, it uses this known profile document to look up the name of the database profile document. Voila! You have a handle on the database profile document with the setup information.

Creating the intermediate profile document
The script below goes in the PostSave event of the database setup profile document. This script creates an intermediate profile document every time you save the database profile document. If you rename your database setup profile document, you must open it and save it in order to update the intermediate profile document with the name of the new database setup profile document.

Sub Postsave(Source As Notesuidocument)
'The RevHistory Setup subform can go on a db setup form of any name.
'However, the RevHistory script must know what form this is.

'This script creates a "link" profile document. The RevHistory script
knows the name of the "link"
'document, and uses it to find the db setup document that contains the
RevHistory setup subform.
'This code automatically creates a "link" profile document, if one does
not exist.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim Profiledoc As NotesDocument
Dim doc As NotesDocument


Set db = session.CurrentDatabase
Set doc = source.Document
Set Profiledoc = db.GetProfileDocument("RevHistory Profile")
Profiledoc.RevHistoryForm = doc.form(0)
Call Profiledoc.Save(False, False)
End Sub





[ Next ]

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
-- Advertisement --

2-Minute Tutorials
How do I...

  • integrate MS Office or OpenOffice with Notes?
  • create cross-tab reports and charts?
  • print serial letters and mailing labels?
  • create PDFs in Lotus Notes?


Check out the 2-minute tutorials here.
-- Advertisement --

How good are your Notes Reports?
Integra for Notes provides high value reporting and data analysis from Lotus Notes databases using Microsoft Word, Excel and PDF files.

  • Enhance traditional static reports with Excel data analysis, pivot tables, macros
  • Report from any Lotus Notes databases without changes to database design
  • Runs reports through a Lotus Notes client and a web browser
  • Enables Report scheduling or distribution by e-mail, printing or storing in a Notes database
  • Allows use of LotusScript for advanced data manipulation
Enables self service reporting capabilities to end-users.

Click For More Info.
Copyright © 1998-2008, ZATZ Publishing. All rights reserved worldwide.
Editor's Login