brMoveNext Method Example

Sub Main()

Dim oEnv As New clsD3Environment

Dim oConn As clsD3Connection

Dim oFile As clsD3File

Dim oIndex As clsD3Index

 

Set oConn = oEnv.brOpenConnection("ODBC", "Production") 

Set oFile = oConn.brOpenFile("customers")

 

On Error GoTo D3ErrorHandler

 

' If there is not an existing index on attribute 1,

' then the D3ErrorHandler will create an index.

Set oIndex = oFile.brRoot("a1")

 

' brMoveNext is the first index function to

' be performed so the index will be traversed

' from the beginning.

Do While oIndex.brMoveNext

' brIndexId returns the item-ids from the

' customers file that is the customerid.

' brIndexKey returns the customer's name (attribute1).

Debug.Print oIndex.brIndexId, oIndex.brIndexKey

Loop

 

oConn.brCloseFile oFile

oEnv.brCloseConnection oConn

Set oEnv = Nothing

Exit Sub

 

D3ErrorHandler:

Select Case Err.Number

Case d3SrvErr_NotRoot

oFile.brCreateIndex "a1", True

Case Else

End

 

End Select

Resume

End Sub