Method
Specifies that an error will not be caused if a key that is being
requested cannot be found.
Category
Errors
Syntax
Sub AllowKeyNotFound
Example
CF1.HideError = False
'Allow
'CF1.AllowKeyNotFound
CF1.OpenTable hTable, CLng(frmCfrontTest.Text1(cf.TableNoCreate).Text)
longArray(0) = 1
longArray(1) = 2 'not a key
longArray(2) = 0
tmpVar = longArray
CF1.AllowKeyNotFound
tmpVar2 = CF1.SetCurrentKey(hTable, tmpVar)
If tmpVar2 = False Then
logWr "AllowKeyNotFound OK"
Else
logWr "AllowKeyNotFound failed"
End If
CF1.CloseTable hTable
Comments
This function only allows the error to occur for one function call.
It must be set each time you want to use it (as opposed to
disabling the error for your application as a whole).
This function works as if HideError had been set to TRUE before a function that tries to use a key is called, and HideError is reset to FALSE afterwards. This means that it is shorthand for a construction like the following (where Cf is a C/FRONT OCX object):
Cf.HideError = TRUE
Cf.FunctionThatUsesKey
Cf.HideError = FALSE
Using this function also means that LastError cannot be used to retrieve an error code. You have to use the return value of the function, as follows:
Cf.AllowKeyNotFound
Ret = Cf.FunctionThatUsesKey
If Ret <> TRUE Then
' handle error
AllowKeyNotFound affects the SetCurrentKey function.