accdbExe

accdbExe
لینک سایر سایت‌های آموزش Access

اطلاعات تماس و ارسال نظر

شروع کار از: فروردین 1402

Error Handling


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


On Error Statement
Enables an error-handling routine and specifies the location of the routine within a procedure; can also be used
to disable an error-handling routine.
Syntax
On Error GoTo line
On Error Resume Next
On Error GoTo 0
The On Error statement syntax can have any of the following forms:
Statement Description
On Error GoTo line Enables the error-handling routine that starts at line specified in the required
line argument. The line argument is any line label or line number. If a runtime error occurs, control branches to line, making the error handler active.
The specified line must be in the same procedure as the On Error statement;
otherwise, a compile-time error occurs.
On Error Resume Next Specifies that when a run-time error occurs, control goes to the statement
immediately following the statement where the error occurred where
execution continues. Use this form rather than On Error GoTo when
accessing objects.
On Error GoTo 0 Disables any enabled error handler in the current procedure.
Remarks
If you don't use an On Error statement, any run-time error that occurs is fatal; that is, an error message is
displayed and execution stops.


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


Resume, Resume Next, Resume Line ()
Resumes execution after an error-handling routine is finished.
Syntax
Resume [0]
Resume Next
Resume line
The Resume statement syntax can have any of the following forms:
Statement Description
Resume If the error occurred in the same procedure as the error handler, execution resumes
with the statement that caused the error. If the error occurred in a called procedure,
execution resumes at the statement that last called out of the procedure containing the
error-handling routine.
Resume Next If the error occurred in the same procedure as the error handler, execution resumes
with the statement immediately following the statement that caused the error. If the
error occurred in a called procedure, execution resumes with the statement
immediately following the statement that last called out of the procedure containing
the error-handling routine (or On Error Resume Next statement).
Resume line Execution resumes at line specified in the required line argument. The line argument
is a line label or line number and must be in the same procedure as the error handler.
Remarks
If you use a Resume statement anywhere except in an error-handling routine, an error occurs.
Example:
Private Sub

On Error GoTo Error
End Sub
Error:

Resume


دستور نوشتاری فرمان(Syntax) به نحو زیر است:


Error Function
Simulates the occurrence of an error.
Syntax
Error errornumber
The required errornumber can be any valid error number.
Remarks
The Error statement is supported for backward compatibility. In new code, especially when creating objects,
use the Err object's Raise method to generate run-time errors.
If errornumber is defined, the Error statement calls the error handler after the properties of Err object are
assigned the following default values:
Property Value
Number Value specified as argument to Error statement. Can be any valid error number.
Source Name of the current Visual Basic project.
Description String expression corresponding to the return value of the Error function for the
specified Number, if this string exists. If the string doesn't exist, Description contains
a zero-length string ("").
HelpFile The fully qualified drive, path, and file name of the appropriate Visual Basic Help file.
HelpContext The appropriate Visual Basic Help file context ID for the error corresponding to the
Number property.
LastDLLError Zero.
Example:
On Error Resume Next ' Defer error handling.
Error 11 ' Simulate the "Division by zero" error.