Site map | Terms and conditions | Privacy policy

VBA Applications – 3 Ways to Handle Objects in Your Access Database

Implementing Visual Basic for Applications (VBA) code in your Access database is not that hard to do. With a little bit of understanding of how the various VBA components work together, you are ready to begin programming.

VBA is an object-oriented programming language. This means that programmers can create an entire object that contains both data and the operations that it can perform. All code is comprised of individual statements. It is with those statements that you handle these objects.

By using VBA, you can work with objects like tables, queries, forms and reports. You can imagine an object as a physical thing, like a car for example. A car has several properties, such as a brand, a color, doors, a steering wheel and windows.

There are three ways you handle these objects:

1. You manipulate their properties
A property is a physical attribute of the object. Each property can have multiple values. For example the values for the properties of our car object could be, brand (Ford), color (blue), doors (four).
Some properties can be easily changed, others cannot. Changing the color of the car is no big problem for an auto detailer, but changing the number of doors is not possible.

2. You call their methods
A method is an action that can be performed by, or on an object. When you are in your car, you can call the methods start engine or drive. A method causes something to happen. If everything works according to your programming, your car moves forward.

3. You perform their events
An event is something that happens to an object. For example, the car stops when you hit the brakes, or turns when you turn the steering wheel. An event happens when the user does something. The actual doing is the method. Therefore, when you call the method press the gas pedal, the car invokes the event forward.

Now that you know about properties, methods and events, you are well on your way to begin programming in VBA.

Tom Vanhasselt is a MS Access developer with over 15 years of experience.

If you want to acquire the necessary programming skills there are of lot of free courses and sources on the internet. A point of reference could be the Microsoft Developer Network (http://msdn.microsoft.com).

Comments are closed.