Over a million developers have joined DZone.

Microsoft Access Database: The Mindset of the VBA Programmer

DZone's Guide to

Microsoft Access Database: The Mindset of the VBA Programmer

Let's take a look at the mindset of the VBA programmer and establishing a frame of reference as to what we should expect when writing VBA code.

· Database Zone ·
Free Resource

MariaDB TX, proven in production and driven by the community, is a complete database solution for any and every enterprise — a modern database for modern applications.

From my new VBA book due out soon, here’s an extract about the mindset of the Microsoft Access Database VBA programmer.

We need to start by establishing a frame of reference as to what we should expect when we are writing VBA code.

Consider the scenario where you command a child to “open the door.” Think about all the individual actions that it takes to accomplish that one statement. The child has to approach the door, align the hand with the doorknob, move the hand and grasp it around the doorknob, and then twist and pull the doorknob while swinging the arm in an arc motion.

We don’t have to command each specific step, and indeed life would be very tedious if we constantly had to issue commands at such a micro level of detail. However, somewhere along the line, the child had to learn what it meant and all the steps in the process to open a door. The child didn’t have to be told for each step and probably figured it out by observing others and by bumping into themselves a few times.

When working on a computer, it is helpful to remember that computers have to be instructed, basically shown the way on how you want it to do things. Be clear, the first thing to remember about computers is that they can’t do what you didn’t tell them to do.

Therefore, to ask the computer to open the door is meaningless until you actually define the exact steps required to accomplish the task. You can’t rely on the computer to observe and understand the act of opening the door as a child would. Fortunately, you can build upon the work done by other programmers. So, for example, when you want to display a little message box saying, “Hello, World!” you can use a single line of code or instructions as shown below. This combines programming done by others with something you want to be said.

MsgBox “Hello, World!”

Behind the scenes, the instruction (command) MsgBox goes through several steps; it instructs the computer How to create a database in access to draw the box, how to position it, what button to put on it, and how to style it.

All of those details are abstracted away from us, which makes our task so much easier. Knowing that the computer needs every step to be defined, you can appreciate the benefit of being able to leverage existing programming and commands to write your own code. But it’s still upon you to supply the missing pieces, like the actual message “Hello, World!” Remembering the general rule that it can’t do what you didn’t tell it to do is invaluable in programming.

Microsoft Access

When writing code, you are working with a type of program called a compiler, which is responsible for translating the VBA language into machine language that the computer can understand and execute. As you write code, the compiler provides feedback on whether statements are valid and free of syntax errors (structural errors). When discussing how the computer will react, we will often refer to the compiler or VBA Editor.

MariaDB AX is an open source database for modern analytics: distributed, columnar and easy to use.

microsoft access database ,database ,hello world ,vba editor ,vba code

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}