CREATING USER-DEFINED ERRORS

By using the CVErr() and IsError() functions and the Application.AccessError method, you can create your own functions that can return an error value if an error situation occurs in the function. Here's a short description of each function and method that can be used:

  • The CVErr() function converts a value to an Error data type, assigning it to a Variant variable.

  • The IsError() function checks to see whether a Variant is an Error data type.

  • The Application.AccessError method provides an error description without the error itself.

An example of using these commands is when you divide two numbers—either the function receives a text value instead of the number needed, or a zero is sent. Listing 7.10 shows the cmdTestCVErr_Click ...

Get F. Scott Barker's Microsoft® Access 2000 Power Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.