Generate an automatic view from forms

Generate an automatic view from forms

This script searches forms in a design database and creates one view for each form within all fields. I have coded that script because I always a need a standard view for forms. Before coming up with this script, I had to create the views one by one. Now I can do that with one click.

Sub Initialize
 Dim s As New NotesSession
 Dim w As New NotesUIWorkspace
 Dim db As NotesDatabase
 Dim frm As NotesForm
 Dim vw As NotesView
 Dim frmName As String
 Dim c As NotesViewColumn
 Redim frmNames(0) As String
 
 Set db=s.CurrentDatabase
 i=0
 frmNames(i)=""
 Forall x In db.Forms
  i=i+1
  Redim Preserve frmNames(i) As String
  frmNames(i)=x.name
 End Forall
 
 frmName=""
 frmName=w.Prompt(PROMPT_OKCANCELLIST, 
"Select a Database", 
"Select a database to open.", "",frmNames)
 Set vw=db.CreateView(frmName,
{SELECT FORM = "}+frmName+{"})
 
 '-----------------------------------------------
 ' Elimination of automatically created columns
 '-----------------------------------------------
 i=0
 Forall columna In vw.Columns
  i=i+1
 End Forall
 For j=1 To i
  vw.RemoveColumn 
 Next
 
 Set frm=db.GetForm(frmName)
 Forall f In frm.Fields
  If frm.GetFieldType(f)<>1 Then 
   Set c=vw.CreateColumn(,f,f)
   Print frm.GetFieldType(f)
   Select Case frm.GetFieldType(f)
   Case AUTHORS,NAMES,READERS,1281
    a$={@name([Abbreviate];}+c.Formula+{)}
    c.Formula=a$
   Case DATETIMES,1024
    c.TimeDateFmt=0    
    c.DateFmt=6
    
   Case NUMBERS,768

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

c.NumberAttrib=2 End Select '----------------------------------- ----------------------------------- ' Special cases of columns of type names non-detected by GetFieldType '--------------------------------- ------------------------------------- If Left$ ( f , 2 )="us" Then a$={@name([Abbreviate];}+c.Formula+{)} c.Formula=a$ End If c.FontFace="Arial" c.HeaderFontFace="Arial" c.FontPointSize=9 c.HeaderFontPointSize=9 c.FontStyle=0 c.HeaderFontStyle=0 End If End Forall End Sub

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Guillermo Villanueva. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

This was first published in June 2005

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.