A Final Note on VBA

There is a lot more to the VBA language than we have covered here. In fact, the Microsoft VBA reference manual is about 300 pages long. However, we have covered the main points needed to begin Access VBA/DAO programming. (For a reference on the VBA language, you might want to check out the book VB & VBA in a Nutshell, by Paul Lomax, also published by O’Reilly.)

Actually, many Access VBA programming tasks require only a small portion of VBAs features, and you will probably find yourself wrestling much more with DAO’s object model than with the VBA language itself.

We conclude our discussion of the VBA language per se with a brief outline of topics for further study, which you can do using the VBA help files .

File-Related Functions

VBA has a large number of functions related to file and directory housekeeping. Table 13.1 contains a selection of them.

Table 13-1. Some VBA File and Directory Functions

Function

Description

Dir

Find a file with a certain name.

FileLen

Get the length of a file.

FileTimeDate

Get the date stamp of a file.

FileCopy

Copy a file.

Kill

Delete a file.

Name

Rename a file or directory.

RmDir

Delete a directory.

MkDir

Make a new directory.

In addition to the file-related functions in Table 13.1, there may be times when it is useful to create new text files to store data. VBA provides a number of functions for this purpose, headed by the Open statement, whose (simplified) syntax is:

Open pathname For mode As [#]filenumber

Get Access Database Design and Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.