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
From the course: Access: VBA
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…
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 Access data types3m 53s
-
(Locked)
Declare variables and require declaration before using5m 28s
-
Manage variable scope4m 47s
-
(Locked)
Define constants and static variables7m 23s
-
(Locked)
Create a calculation using mathematical operators4m 57s
-
(Locked)
Display a calculated result in a message box4m 2s
-
(Locked)
Define an array7m 12s
-
(Locked)
Define and use an object variable3m 57s
-
(Locked)
-
-
-
-
-
-
-
-