Search Tools Links Login

Connect to Lotus Notes View using COM and Loop through records

This piece of code allows you to connect to an existing Lotus Notes View using COM and Loop through the records within that View. This is simple, but for those people out there that deal with Notes and SQL Server/Access databases, then this is a must. Very easy to manipulate.

Original Author: Todd Walling




Be sure to reference the Lotus Domino Object!



Side Effects

None that I am aware of.

API Declarations

' Declare Notes COM variables
Dim n_Session As New Domino.NotesSession
Dim n_Database As New Domino.NotesDatabase
Dim n_Document As NotesDocument
Dim n_ViewEntry As NotesViewEntry
Dim n_View As NotesView
Dim n_ViewNav As NotesViewNavigator
Dim l_TestVariable As String


' Initialize session and set database
  ' Set database
  Set n_Database = n_Session.GetDatabase("Your Server Name", "YourFileLocationYourFile.nsf")
  ' Set to view
  Set n_View = n_Database.GetView("NameOfYourView")
  ' Set view navigator
  Set n_ViewNav = n_View.CreateViewNav
  ' Move to first record
  Set n_ViewEntry = n_ViewNav.GetFirstDocument()
  ' Loop through records within view
  Do While Not (n_ViewEntry Is Nothing)
    ' Set view to document
    Set n_Document = n_ViewEntry.Document
    ' Set local variables
    l_TestVariable = n_Document.GetItemValue("TestFieldName")(0)
    ' Get next entry
     Set n_ViewEntry = n_ViewNav.GetNextDocument(n_ViewEntry)
  ' Clean-up
  Set n_ViewEntry = Nothing
  Set n_ViewNav = Nothing
  Set n_View = Nothing
  Set n_Document = Nothing
  Set n_Database = Nothing
  Set n_Session = Nothing

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 81 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.