Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
Grab All Fields in Database and sort

Hint Short Cut: Add this to your code & documentation to help you find this page.
http://www.notesninjas.com/#DatabaseFields or http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/DatabaseFields


This script grabs all the fields in a database by going through the forms, uniques them and then sorts them.





 

'this code grabs all the fields in the database and sticks them in the flds field
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
fieldCount = 0
Redim Preserve f(0) As String
Forall form In db.Forms
 
 If Isempty(form.Fields) Then
   'Messagebox form.Name & " has no fields"
 Else

  Forall field In form.Fields
   f(fieldcount)= field
   fieldcount=fieldcount+1
   Redim Preserve f(fieldcount)
  End Forall

 End If  

End Forall
'Messagebox "postopen " & Ubound(f)
Dim uiw As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc = uiw.CurrentDocument

Dim doc As notesdocument
Set doc = uidoc.document

Dim fun As Variant
fun =Arrayunique(f)

'Messagebox "postopen " & Ubound(fun)



Dim temp As String
'sort the fun array
For a=1 To Ubound(fun)-1
 For b=Ubound(fun) To a Step -1
  If fun(b) < fun(b-1) Then
   temp=fun(b-1)
   fun(b-1)=fun(b)
   fun(b)=temp
  End If
 Next b
Next a

 'poulate the field in the open form if required
'Call doc.ReplaceItemValue("flds",fun)

 

 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
man and boy by Tony Parsons
British book of the year 2000. Great book, hard to put down, but I nearly threw it away half way through. You'll know why when you read it.
See at: Amazon.co.uk | Amazon.com |