Error Handling

When an error occurs, the error handler displays an error message by default. Depending on the environment in which you use the C/FRONT OCX, you may simply choose to continue execution after an error has occurred - for example, in WordBasic or Visual Basic, execution can be resumed by clicking a button.

Therefore, you may want to process some errors yourself. Alternatively, you can use the StopOnAllExceptions property to make sure that any exception - fatal or non-fatal - will cause execution to stop.

By using HideError, you can turn the display of the default message off, and you can use LastError to test if an error did occur, and proceed accordingly.

Example
This fragment shows how to use HideError:

Cf.HideError = TRUE
Cf.AnyFunction

If (Cf.LastError <> 0) Then

  Call MyErrorHandler

EndIf

Cf.HideError = FALSE

You can also allow some errors to occur by using AllowKeyNotFound, AllowRecordExists, AllowRecordNotFound or AllowTableNotFound. When you allow an error, no error message will be displayed as the condition is not considered an error. Consequently, LastError does not return an error code, but the function itself will still return FALSE. You should test this return value in your code.

Example
The following fragment shows how to use these functions:

AllowKeyNotFound
Ret = Cf.FunctionThatUsesKey

If Ret <> TRUE Then

  ' handle error

Else

  ' proceed

EndIf



© 2009 Microsoft Corporation. All rights reserved.