Chapter 15. USING API CALLS TO EXTEND THE POWER OF ACCESS

IN THIS CHAPTER

API (application program interface) calls, sometimes also referred to as routines, are called from dynamic link libraries (.dll). These routines allow you to expand the power that Access already gives you in the VBA programming language.

One example of using an API call would be when you need to connect to a share on a network programmatically. Although you can't do this with VBA, there are API routines that will accomplish this.

Access continues to expand in its native language, including adding features that you once handled by making API calls. Some tasks still need to be handled through programming the API.

API calls are used in most languages that allow you to develop at the system level. The good news is that when you learn the calls in one language, the switch to another language to make the same call doesn't require a great deal of modification. This is especially true between VB and Access VBA. In fact, many of the API calls you “borrow” will possibly come from applications written in Visual Basic.

Note

It's highly recommended that you “borrow” code that has already proven to work with the API call you're trying to use, for two reasons:

  • Why re-create something that has already been done?

  • One of the most frustrating things about using API calls is the lack of good sample code for all the functions.

Finding code that already has a good wrapper function around the API call also will save countless hours of development time.

Chapter 16, “Extending Your VBA Library Power with Class Modules and Collections,” covers class modules, which are great for encapsulating code and making it very painless to use API calls. The last example in this chapter, using the Open File dialog, is used in the next chapter with a class module.


Caution

The frustration factor is especially true because when you're dealing with API calls, you can GPF (general protection fault) quite easily if the calls aren't set up correctly. GPFs are more controlled in Windows 95/98/NT in that you don't have to reboot Windows. However, you can pretty well count on losing whatever work wasn't saved.The moral of the story is save often, especially before you try out an API call.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.207.129