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.

Display a calculated result in a message box

Display a calculated result in a message box

From the course: Access: VBA

Start my 1-month free trial

Display a calculated result in a message box

- [Instructor] One useful to communicate the results of a sub routine or function is to create a message box. In this movie, I will show you how to create a message box using VBA code. I've opened the course database, and now I will switch over to the Visual Basic editor by pressing Alt F11. Here in the Visual Basic editor, I can go to the insert menu and click module and that creates a code module that I can use to create a sub routine. In this case, I call a sub routine using the sub keyword, and I'll call it display value, and then I'll just type () because I won't be passing any values to it. Everything will be contained within the sub routine. I'll press enter a couple of times to give myself some blank space to work with, and you'll notice that Access included the end sub line on its own, you need that to indicate the end of the sub routine. I'll start by defining a variable and that'll be a string, and I'll just make it message as string. And then I'll say sMessage="Welcome to…

Contents