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.

Summarize values in a table field

Summarize values in a table field

From the course: Access: VBA

Start my 1-month free trial

Summarize values in a table field

- [Instructor] You can use VBA code to view, edit, or delete individual rows, but you can also use VBA to summarize all the values in a field in one calculation. For example, you could find the average or a sum of the values in a quantity column. In this movie, I will show you how to create the code to do just that. I have opened the course database, and I'll press Alt + F11 to go to the Visual Basic Editor. I need to create a code module, so I'll click Insert to open the Insert menu, and click Module. Now I can create a subroutine that summarizes the values in the quantity column of the orders table. So I will call it Sub, 'cause I'm creating a subroutine, Summarize, and then open and close parentheses 'cause we're not passing any arguments. I will declare my variable for the values. So Dim dValue as Double. And then just a MsgBox with the following prompt, that is the text that's displayed. And that will be DAvg, followed by a left parenthesis. Then we need to have the expression…

Contents