Community articleGetPrevious function
Added by IBM contributorIBM on May 2, 2012
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 GetNext, is used to traverse horizontally along the form hierarchy. GetPrevious returns the previous node in the tree. For instance, if you call GetPrevious on the Page1 node in your form, it will return the global page node.


   Function GetPrevious() As IFormNodeP


There are no parameters for this function.


The IFormNodeP that represents the previous node or null if no such node exists. An exception is thrown if an error occurs.


The following sample function receives any form node and returns a reference to the first 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 GetPrevious to locate the first page in the form and calls GetReferenceEx to retrieve a reference to that node.
   Function GetFirstPage(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
         ' the page node.
         Do While (Not(MainNode.GetNodeType = UFL_PAGE))
            Set MainNode = MainNode.GetParent
      End If
      ' Set TestNode to be the MainNode before beginning the next loop
      Set TestNode = MainNode
      ' Locate the first page node (the global page) by iterating through the
      ' siblings of the located page node.  At the end of this loop, TestNode
      ' will be Nothing and MainNode will be the global page node.
      Do While (Not(TestNode Is Nothing))
         Set MainNode = TestNode
         Set TestNode = TestNode.GetPrevious
      ' Locate the first page of the form by getting the first sibling of the
      ' global page node.
      Set MainNode = MainNode.GetNext
      ' Get a reference to the page and return the reference to the caller
      GetFirstPage = MainNode.GetReferenceEx(vbNullString, Nothing, _
         Nothing, False)
   End Function

Parent topic:
FormNodeP functions