From the course: Access: VBA

Unlock the full course today

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

Define and use an object variable

Define and use an object variable

From the course: Access: VBA

Start my 1-month free trial

Define and use an object variable

- [Narrator] When you want to use VBA to manipulate an open table, form, or other database object, you need to assign that object to a variable. Those variables are called object variables. And in this movie, I will show you how to work with them. I have opened the course database and I have opened the product and categories forms so I can work with them in VBA. With those two objects open I can press alt F11 to move to the visual basic editor. In the visual basic editor I will create a code module. So I'll go to the insert menu and click module. And an empty code module appears. The first thing I'll do is create my subroutine. So I'll type sub and then show form name and open and closed parenthesis because I'm not adding any arguments to be used in the subroutine. And I'll press enter a few times to give myself some room to work. The first thing I need to do is to declare a variable that will hold the form. And that will be dim. The variable name is my form. And we will declare it as…

Contents