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
- [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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Introduction to Access data types3m 53s
-
(Locked)
Declare variables and require declaration before using5m 28s
-
Manage variable scope4m 47s
-
(Locked)
Define constants and static variables7m 23s
-
(Locked)
Create a calculation using mathematical operators4m 57s
-
(Locked)
Display a calculated result in a message box4m 2s
-
(Locked)
Define an array7m 12s
-
(Locked)
Define and use an object variable3m 57s
-
(Locked)
-
-
-
-
-
-
-
-