Declaring variables lets you store specific values for later use. In this video, learn how to 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 Currency,…which is one of the available data types,…
- Working with macros
- Running a VBA procedure
- Debugging VBA code
- Defining variables, constants, and calculations
- Displaying a calculated result in a message box
- Repeating tasks with loops
- Manipulating database objects
- Adding, editing, and deleting records
- Looking up values in a table
- Automating processes with macros
Skill Level Advanced
What you should know1m 38s
1. Introduction to Visual Basic for Applications
2. Define Variables, Constants, and Calculations
3. Add Logic to Your VBA Code
4. Debug Your VBA Code
5. Manipulate Database Objects Using DoCmd
6. Read and Manipulate Table Data
7. Manipulate a Database Using the Application Object
8. Control Forms and Reports Using the Me Object
9. Automate Processes Using Macros
Next steps1m 7s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.