NextKey

Method
Retrieves the table key that comes after a specified table key.

Category
Keys

 

Syntax
Function NextKey(ByVal hTable As Long, ByVal Key As Variant) As Variant

hTable
The handle to the table.

Key
The key.

 

Example

CF1.OpenTable hTable, 18

  tmpVar = Empty

  tmpLong = 0

  tmpVar = CF1.NextKey(hTable, tmpVar)

  If VarType(tmpVar) = vbVariant Then

  While Not IsEmpty(tmpVar)

  tmpLong = tmpLong + 1

  tmpVar = CF1.NextKey(hTable, tmpVar)

  Wend

  logWr "Scanned through " & Trim$(Str$(tmpLong)) & " keys with NextKey"

  Else

  logWr "NextKey failed"

  End If

  CF1.CloseTable hTable

 

Comments
NextKey returns the key that comes after the specified key in the table. Both the parameter Key and the function result are variant arrays containing the numbers of the fields that make up a key.

This function does not influence the definition or selection of the keys; table keys are defined in C/SIDE.

If Key is set to an empty variant, the first key for the table is returned. The first key is the primary key. If NextKey is then called using the first key as the argument, the second key is returned, and so on. When the function reaches the end of the key list, it returns an empty Variant. In this way, NextKey can scan the entire list of table keys. The scan is restricted to the active keys and excludes the inactive ones.

For more information about keys, see the Application Designer’s Guide.



© 2009 Microsoft Corporation. All rights reserved.