Access.2007.VBA.Bibl..

(John Hannent) #1
n An add-in can display forms, usually as unbound dialogs. Typically, all add-ins except
menu add-ins use one or more forms (and menu add-ins can use forms too). The Extras
2007 add-in has a setup form where users can enter information that will be used by var-
ious procedures in the add-in.
n You can reference tables in the add-in library database using the CodeDbsyntax, which
lets you store add-in data in tables if needed. This is useful when you want to store infor-
mation that will be used for all databases running the add-in, for example the lists of table
and query prefixes for excluding tables and queries from listing, in the Extras 2007 add-in.
n Replace macros and queries with code run from public functions, so they can be run
directly from the library’s module(s).
n Bound forms run from an add-in have as their record source tables in the code database,
not the calling database. If the form needs to display data from the calling database, it
must be copied to a table in the code database after being filled with data from the calling
database, as I do in the Extras 2007 add-in for backup options, and table and query
fields.
n The DDL CreateTablestatement creates a table in the current database; if you need to
create a table in the code database, you have to use the more complex TableDef
method in DAO, specifying CodeDbas the database in which to create the table.
n An add-in intended to work in both Access 2007 and earlier versions of Access may need
to process both .mdb and .accdb extensions, or deal with the new Attachment data type.
n When the CopyObjectmethod is run from an add-in, the code looks for the source
object (the SourceObjectNameargument) first in the library database, and then in the
current database. This may require you to create a copy of a table, say with “Blank” at the
end of its name, in order to copy a fresh, blank table to the calling database, overwriting a
filled table, as I do in the Extras 2007 add-in code. Otherwise, you will end up copying
the filled table from the calling database back to itself.
n When run from a library database, the RunSQLmethod of the DoCmd object works on
tables in the calling database, and the OpenQuerymethod works on tables in the code
database.

Tips on Add-in Construction ..................................................................................


When creating Wizard-type add-ins, you can make then more user-friendly by modeling their
appearance after the built-in Access add-ins. Access 2007 has many new interface features, but the
wizards look much the same as in earlier versions (Access 97–2003), though there may be some
cosmetic differences if you are running Office 2007 over Windows Vista. To make your Wizard
forms look like the familiar Access wizards and builders, use the settings listed here:

n Set forms’ AutoCenter property to Yes.
n Turn record selectors off.
n Set scroll bars to Neither.

Part III Adding More Functionality to Office

Free download pdf