Introducing VBA s Built-in Functions

 < Day Day Up > 

Introducing VBA's Built-in Functions

VBA is considered a high-level language, which means it can take a while to master. On the other hand, the combination of Access and VBA is flexible enough that you can start using VBA to automate your Access applications right out of the box, with just a little reading and preparation.

There are a number of functions that perform dozens and dozens of tasks and calculations for you. While you're learning, don't make the mistake of re-inventing the wheel use the functions VBA provides. You'll find them easy to use, flexible, and dependable.

Like the function procedures that you write yourself, the built-in functions return a value. In addition, most functions rely on both required and optional arguments. Thanks to IntelliSense, there's not much guesswork. As you enter the function, the VBE displays a list of context-sensitive suggestions. Keep in mind the following when working with VBA functions:

  • Functions expect arguments of a certain data type. If you supply the wrong type of data, VBA will return an error.

  • The values returned by each function are of a specific data type. Be familiar with the type of data returned so you don't introduce unintentional errors into your code.


Knowing which function to use, or if there even is an appropriate function available can be one of the biggest hurdles for new VBA users. Fortunately, help is close at hand. In the VBE, choose Help, Microsoft Visual Basic Help to open the Help task pane. In the Table of Contents list, click the first item, Microsoft Access Visual Basic Documentation. Click the Functions or the Statements link in the expanded list and then click the alphabetized listing links to view what's available.


You might find the terms function and statement used interchangeably. Technically, statements have been around for the duration and are much older than any VBA functions. As Access and VBA have matured with an expanding object model, many statements have been replaced with functions. I recommend that you use functions whenever possible, because they represent the most up-to-date functionality. Seemingly similar statements are usually included for backward compatibility. However, not all statements are obsolete.

Throughout this chapter (and the entire book), I use the most up-to-date functions, not the older statements, even if they exist. Nor do I bother to tell you when there are older, comparable statements. There's simply no reason for you to use them unless you inherit an application that uses them.

     < Day Day Up > 

    Automating Microsoft Access with VBA
    Automating Microsoft Access with VBA
    ISBN: 0789732440
    EAN: 2147483647
    Year: 2003
    Pages: 186 © 2008-2017.
    If you may any questions please contact us: