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.
Declare variables and require declaration before using
From the course: Access: VBA
Declare variables and require declaration before using
When you write Access VBA code, you'll often use variables to represent numbers, character strings, and objects. In this movie, I will show you how to define, or declare, those variables and reduce the likelihood of errors by requiring that you declare variables within a code module. I have opened the course database and I'll press Alt + F11 to move to the Visual Basic Editor. Now that I'm here, I can create a code module by going to the Insert menu and clicking Module and there is my code module. I'll go ahead and start a subroutine. So, I'll type "Sub" and I'll call it CalcComm, and that's just short for calculate commission. I'm not giving it any arguments, so I'll type an open and close left parenthesis and press Enter a couple of times to give me the End Sub line and also some room to work. I'll start by declaring a variable using the Dim keyword. What I'm doing is declaring, or dimensioning, a variable and providing information about it. So, if I were to have curValue 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)
-
-
-
-
-
-
-
-