OpenNTF.org - grab a document from a databas
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
grab a document from a database ( shorten your code ) 
Rating:
Not Rated Yet 
Contributor:
Mike Mortin 
Category:
Lotusscript 
Type:
Searching 
Notes Version:
R6.x, R8.x, R7.x 
Last Modified:
13 Nov 2008 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
Public Function GetDocFromDb( db As NotesDatabase, viewName As String, key() As Variant, exact As Boolean ) As NotesDocument

' returns the first doc based on a search key
' posted to http://www.openntf.org/projects/codebin/codebin.nsf/CodeBySubCategory/D8474BE8C4FEEB35862574EF00628013
' written by Mike Mortin
Dim view As NotesView

' get the view
Set view = db.GetView(viewName)

' get the doc from the key
Set GetDocFromDb = view.GetDocumentByKey(key, exact)
End Function

Usage / Example
Use this to shorten your code if you don't need to declare the variables other than for the lookup. It works well when placed in a common script library.
Just define each key per column you want to return on. Here, assume the 2 columns in the 'PeopleByLastFirst' view are last name and first name

...
key(0) = "Mortin"
key(1) = "Mike"
set doc = GetDocFromDB(nabDb, "PeopleByLastFirst", key, true)
...
 Comments

No documents found

 Add your comment!