From the course: Access: VBA

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Create, export, and delete code modules

Create, export, and delete code modules

From the course: Access: VBA

Start my 1-month free trial

Create, export, and delete code modules

- [Instructor] When you are ready to write VBA code, that can be used anywhere in your database, not just attached to a particular form or other object. You can create a code module. I'll demonstrate how to do that in this movie. And I have opened the course database and moved to the Visual Basic Editor. I'll press Alt + F11. So here I am. If I want to create a new code module, I go to the Insert menu, and click Module. And here I have my code module. Any code module that you create using this method, starts with Option Compare Database. And what that does is take a look at the database to see if there are any changes that the code needs to account for when it runs. So that's there automatically and you shouldn't delete it. In this code module, you can create subroutines or functions. I'll create a subroutine that starts with the keyword Sub. And I'll just call it Hello. We don't need to send or pass any information to the subroutine. So I'll just time an open and close parenthesis…

Contents