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.
Create a function
- [Instructor] There are two types of procedures that you can create in Access VBA. Those are subroutines and functions. In this movie I will discuss functions. A function returns a value that you can use in a calculation, where a subroutine only does calculations within that particular subroutine. I show you how to create a subroutine elsewhere in the course. So in this movie I will show you how to create a function. I'll start by switching to the Visual Basic Editor. So I'll press Alt F11 and then once I'm here, I'll go to the insert menu and click module. And my code module appears. To create a function, I will type the word function and now I need to give the function a name. For this straight forward example I'll just type Multbypi, and as you can imagine we'll be multiplying a number by pi. Then a space and a left parentheses. We need to give this particular function a value to work with. It's called an argument. And we need to define it, or them, within parentheses. So I'll…
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 object-oriented programming1m 59s
-
(Locked)
Examine the Access object model4m 57s
-
(Locked)
Work in the Visual Basic Editor3m 52s
-
(Locked)
Create, export, and delete code modules5m 47s
-
Create a subroutine5m
-
(Locked)
Create a function5m 26s
-
(Locked)
Add comments to your code4m 15s
-
(Locked)
Run a VBA procedure5m 7s
-
(Locked)
-
-
-
-
-
-
-
-
-