Search DominoPower's 11,974 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
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. Roll over 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


1  ·  2  ·  Next »
Other articles you might like
Home > Lotus Technologies > LotusScript (64 articles)
   When the debugger won't debug hidden code that isn't hidden
   What to do if the LotusScript debugger won't single-step over code
   Little known traps about Lotus Notes fields
Home > Lotus Technologies > Application Development (48 articles)
   An application for scanning physical mail and distributing it virtually
   How hide-whens in Rich Text can ruin your whole day (and what to do about it)
   Little known traps about Lotus Notes fields
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Lotus must open source Notes and Domino
It's time for Lotus to double-down on Linux and open source
Back to basics with Notes: what you can do now
Back to basics with Notes: what are the basics?
Back to basics with Notes
Smart Upgrade bug in Domino 8.5.1 (and some work-around tips)
Hands-on with XPages and the Lotus Solutions Catalog
Latest Lotus Headlines
IBM Lotus Notes 8.5.2: Upgrading your Icons from 16x16 to 32x32
IBM killed the Sandbox !
Followup on Cut and Paste problem in 8.5.2
Save us from our users: Doomsday Weekend 3
iNotes 8.5.2 Security Change With XSS
Warning about multiple Traveler installations in your domain
Admins: Modifying, Updating or Fixing your Config
>> Read all the news
More from the ZATZ journals
Computing Unplugged: Introducing the Jones family and their full-family backup challenges
David Gewirtz Online: CNN commentary and analysis
OutlookPower: Hands on debugging a broken Outlook forwarding rule
-- Advertisement --

Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.

The many included activities and demos will make you a pro! Expert instructor help is a click away.

Click here to try a FREE demo course!!

-- Advertisement --

Integrate your Notes Applications with Microsoft Office and Symphony
Integra for Notes Integrates Microsoft Office and/or IBM Lotus Symphony
Requires NO change to the design of the appliation or Installations of DLL's and EXE's
  • Integra is a ready to use solution, enhance static reports with Excel data analysis, pivot tables, macros
  • User friendly aproach, using a point and click access to features
  • Reports from any Lotus Notes databases
  • Runs reports through a Notes client, web browser and scheduled basis
  • Allows use of LotusScript for advanced data manipulation
  • Enables self service reporting capabilities to end-users


Learn more at www.integra4notes.com.
ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login