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

Create a function

From the course: Access: VBA

Start my 1-month free trial

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…

Contents