Free Access programming tutorial Video 6

In this part of the video series you’ll learn:

How to call other procedures.
How to better organize your code.
Common Errors
Unit Wrap up questions:
1. The process of combing values to form a single string expressions is called what?
A: concatenation
2. What is the proper order of objects containing other objects?
A: Modules contain procedures that contain statements.
3. The Option Explicit statement is used for what?
A. Prohibit the use of variables that have not been declared.
4. What structure would be best suited for when one variable may have 5 different
values representing 5 different outcomes?
A. The Select Case structure.

A few word about error handling, before you take the quiz

Your normal errors will happen not as a result of the Access application (this may happen rarely, Access is a MS product after all 🙂 )

Errors will commonly be found at run-time as a result of your logic or syntax (use Option Explicit to help avoid these misspelling errors).

Leaving (Exiting) and Error-Handling Routines

You can exit an error handler using an Exit or Resume statement.

The Resume statement returns program control back to the main procedure. It returns back to statement that caused the error in the first place, and then the statement is run again.

When you use the Resume Next statement you will return to the line after the line that caused the error.

Consider this error trap:

Sub OpenReport()

    On Error GoTo errHandler
    DoCmd.OpenReport "CoolReport", acViewPreview
    MsgBox "Done"
    'exit the procedure so you don't go to the label if there is not an error.
    Exit Sub

    MsgBox "That report doesn't exist"
    'Resume 'send you into an infinite loop and never gets to the message box
    Resume Next 'informs you of error, but allows you to proceed gracefully
End Sub

The report doesn’t exist, so you immediately get thrown to the error handler. Resume will take you back to the line that caused the error, so you end up in an infinite loop where you will have to end the Access process using the Task Manager.

However, Resume Next in this situation will allow you to gracefully advance to the next line -> MsgBox “Done”

Just as a note, you may want to use the properties of the Err object to help you out in your error handling:

I have used Err.Number and Err.Description often in my error handling routines.

(Hint Err.Source is a valid option too)

Click The Link To Learn more about >> Error Handling In VBA

<< Free Access programming tutorial Video 5

Free Access Programming tutorial Video 7>>

Check for understanding – Video 6

Offsite Related Information:

“Go Fund Me” Page

($5 suggested amount)

(…10% of your gift amount will go to charity)

Free! Subscribe To Our YouTube Channel!

Free MS Access VBA Programming Course

Facebooktwitterredditpinterestlinkedinmailby feather
Tags: , , , , , , , , , , , , , ,