Exercises


1. 

What is the difference between a standard library and an external library?

image from book

2. 

What is automation, and what are some examples of ways to use automation?

image from book

3. 

How do you create a code library, and what are some advantages of doing so?

image from book

4. 

What is a transaction, and how do you implement one?

image from book

Answers

1. 

A standard library can be added using Tools image from book References. You can then work with the objects of that library from within your code and have full access to the available properties, methods, and events as you type your code. An external library is more complicated to work with and requires an explicit declaration in the General Declarations section, as well as a procedure call from within your VBA code. External libraries must be declared with the exact syntax, or an error will occur.

2. 

Automation allows one application to control another application, such as Access controlling Word. You can use automation to create new Excel spreadsheets, to create new Word documents, or to manipulate Outlook objects such as e-mails, contacts, and calendar entries. These are just a few examples of using automation. In order to use automation, you must add a reference to the library that corresponds to the application you want to control.

3. 

A code library can be created by simply creating a new Access database that contains the code you want to have reused by other applications. Code libraries are a good idea for storing generic code that multiple applications might want to take advantage of, such as error-handling routines. Instead of copying the same procedures into every application and then having to update multiple locations, you can simply point each application to a single Access database. To add a reference to a library, you simply select Tools image from book References and then browse to the location of the Access database you want to use as a library. After the reference has been added, you can call the functions and sub procedures in the library just as if it were contained in your local module.

4. 

A transaction is a group of database actions that should succeed or fail together. You can use the BeginTrans, CommitTrans, and RollbackTrans methods of the ADO Connection object to implement transactions. If the updates all succeed, then all of the updates can be committed to the underlying database using the CommitTrans method. If any one of the updates fails, then all of the changes can be rolled back using the RollbackTrans method.




Beginning Access 2007 VBA
Beginning Access 2007 VBA
ISBN: 0470046848
EAN: 2147483647
Year: 2004
Pages: 143

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net