Constants are variables that never change, while static variables accumulate values while a procedure runs. In this video, learn how to define constants and static variables.
- [Narrator] Normally, when you work with variables…in a code module, you want the variable's values…to reflect the current run of the code…and then reset to zero when the module runs the next time.…If you want a variable to retain the same value…throughout the code run,…you can define it as a constant.…If you want the variable to remember its value…until you close the database,…you can define it as a static variable.…In this movie, I will show you…how to define constants and static variables.…I've opened the course database…and I'll press Alt + F11 to move to the Visual Basic editor.…
From here, I can click insert and module…to create a code module.…And I'll need some space,…so I will increase the size of the window.…I'll start by creating two subroutines.…The first is Sub…DelCharge.…This'll be calculating a delivery charge…and I will type open and closed parentheses,…with nothing in between,…because I'm not passing any values in.…So, I'll type Dim curSaleValue…as Currency,…then a comma, then curSaleTotal…as Currency,…
- 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.