Message boxes display text of your choosing and require a user to click a button to dismiss them. In this video, learn how to 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 the database"…because it's again, text that I need to indicate…
- Working with macros
- Running a VBA procedure
- Debugging VBA code
- Defining variables, constants, and calculations
- Displaying a calculated result in a message box
- Repeating tasks with loops
- Manipulating database objects
- Adding, editing, and deleting records
- Looking up values in a table
- Automating processes with macros
Skill Level Advanced
What you should know1m 38s
1. Introduction to Visual Basic for Applications
2. Define Variables, Constants, and Calculations
3. Add Logic to Your VBA Code
4. Debug Your VBA Code
5. Manipulate Database Objects Using DoCmd
6. Read and Manipulate Table Data
7. Manipulate a Database Using the Application Object
8. Control Forms and Reports Using the Me Object
9. Automate Processes Using Macros
Next steps1m 7s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.