Community articleGetNext function
Added by IBM contributorIBM on August 15, 2011
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.


This function, along with GetPrevious, is used to traverse horizontally along the form hierarchy. GetNext returns the next node in the tree. For instance, the page node corresponding to the first page of your form can be reached by calling GetNext on the global page node.


   Function GetNext() As IFormNodeP


There are no parameters for this function.


The IFormNodeP that represents the next node or null if the next node does not exist. An exception is thrown if an error occurs.


The following sample function receives any form node and returns a reference to the last page of the form. First, the function uses GetNodeType to determine if the supplied node is a the form level. If so, the function uses GetChildren to locate the first page node. If not, the function uses GetParent to locate a page level node. The function then uses GetNext to locate the last page in the form and calls GetReferenceEx to retrieve a reference to that node.
   Function GetLastPage(Node)
      Dim MainNode, TestNode ' objects
      Set MainNode = Node
      ' Locate the page level node that is the nearest ancestor or child of
      ' the current node.  If the node is a form node, get the child.  If the
      ' node is any other type, get the parent until a page node is 
      ' retrieved.
      If MainNode.getNodeType = UFL_FORM Then 
         Set MainNode = MainNode.GetChildren
         ' Locate the page node of the form by iterating through the parents
         ' of the supplied node.  At the end of this loop, MainNode will be
         ' a page node.
         Do While (Not(MainNode.GetNodeType = UFL_PAGE))
            Set MainNode = MainNode.GetParent
      End If
      ' Set TestNode to be the MainNode (the page node) before beginning the
      ' next loop.
      Set TestNode = MainNode
      ' Locate the last page node by iterating through the siblings of the
      ' global page node.  At the end of this loop, TestNode will be Nothing
      ' and MainNode will be the last page node.
      Do While (Not(TestNode Is Nothing))
         Set MainNode = TestNode
         Set TestNode = TestNode.GetNext
      ' Get a reference to the MainNode and return that reference to the
      ' caller.
      GetLastPage = MainNode.GetReferenceEx(vbNullString, Nothing, Nothing,_
   End Function

Parent topic:
FormNodeP functions