My.ADVISOR.com Sign-In
ID
Password

Member Center / Sign-Up
Go to Article
Advanced Search 

ACCESS DEVELOPMENT

Access Architecture Secrets

Technical Editor and Advisor DevCon speaker Mike Groh shares a tip on building your own Access libraries.

By Mike Groh, Technical Editor, Access-VB-SQL Advisor Magazine


Access' library-based architecture lets you extend its capabilities by adding your own libraries. Just as a wizard's code is accessible from your applications, your own code can be globally available to the Access applications you build.

You can try it out yourself: Begin by creating a new, empty Access database and importing all the code modules you want to package as a global resource for your Access applications. Next, be sure all the procedures are declared globally or publically so they'll be accessible from other MDBs. Finally, create an MDE from this database to create a permanent, secure library of your routines.

At this point, you have several ways to make the code stored in your MDE library accessible to other databases. Perhaps the easiest way is to put the MDE on a file server somewhere on the network. Then, add a reference to the MDE to each database that needs its code.

The reference can be added manually or through code. Adding a reference through the Tools > References dialog is easy. Simply open the dialog, select the Browse button, and navigate to your MDE file. After you've selected your MDE, all the publicly declared procedures are accessible to the MDB.

But, it might be more useful to add the reference through code. Using code means you don't have to instruct your users how to perform this task, and the code can even repair a broken reference if necessary. This code segment shows how it's done:

Private Sub cmdAddTheReference_Click()
  Access.References.AddFromFile <Path-To-MDE-File>
End Sub
An example might be:
Access.References.AddFromFile _
   "\\Elvis\Drive_C\PublicCode\MyCode.mde"

In this case, I used a universal naming convention (UNC) path to eliminate the problems inherent when using mapped network drives. As long as Windows can resolve the path (\\Elvis is the server's name, Drive_C is a shared drive, and PublicCode is a folder), the VBA engine is able to use the code in the MDE. It's also possible to put tables, forms, reports, and other database components in an MDE library. For instance, an MDE library might be the ideal place to keep your error logs, message dialogs, and lookup tables (ZIP codes, etc.). You can even keep reports and data-entry forms in the MDE. Because it's an MDE, you know your users won't be trying to "improve" your forms and reports!

One caveat: Many Access developers are still using DAO to work with Access data. Keep in mind that CurrentDb refers to the database that's open right in front of the user. Use CodeDb to refer to the database where the code resides. When running code stored in an external MDE library, CodeDb references the library database, not the working MDB. Therefore, use DAO code like this to open a recordset in the library database:

Set rs = _
   CodeDb.OpenRecordset("tblMyTable", dbOpenDynaset)

When using ADO, be sure to correctly reference either the library or user database in the Connection or Recordset object's ConnectionString property.

To learn more Access architecture secrets, don't miss Mike Groh's session at the June 2003 Advisor DevCon in Las Vegas (http://Advisor.com/MSDevCon).


Access Architecture Secrets

No reader comments ... yet.

    What do YOU think about this topic? Share your advice and thoughts using this form.

    Your Name

    REQUIRED : PUBLIC

    Your E-Mail

    REQUIRED : PRIVATE

    Job, Company

    OPTIONAL : PUBLIC

    City, State, Country

    OPTIONAL : PUBLIC

    Your Web Site

    OPTIONAL : PUBLIC

    Your Comment

    Please help everyone by keeping your comments on-topic, using clean language, and not defaming or making personal attacks.


    Your e-mail address is required, but it will not be displayed to the public or given to anyone. See our Privacy Policy. Comments become visible after they pass our spam filter, and spammers and abusers are permanently blocked. Please report spam or abuse.

    Technical Editor Mike Groh is a consultant, trainer, and contributor to many computer books, as well as a trainer for AppDev. He frequently speaks on Access and Visual Basic topics at Advisor DevCon and presents for Advisor Academy Seminars on CD (AdvisorAcademy.com). mikegroh@earthlink.net.

    Printer-friendly
    page layout

    Keyword Tags: Application Development, Database, Database Development, Microsoft, Microsoft Access, VBA - Visual Basic for Applications

    ADVISORAMA
    Everybody talks about wanting to change things and help and fix, but ultimately all you can do is fix yourself. And that's a lot. Because if you can fix yourself, it has a ripple effect.
    -- Rob Reiner, director & actor

    ARTICLE INFO

    DataBased Advisor

    Web Edition: 2003.04.21, Doc #12298

    FREE ACCESS FREE ACCESS

    SUBSCRIPTION STATUS
    You are not signed-in. If you are a subscriber to this publication, sign-in above to access locked articles. To subscribe or renew go to www.AdvisorStore.com.

    Subscribe to FileMaker Advisor Magazine

    Read the advanced guide to creating custom business database solutions with FileMaker software. Subscribe now to gain access to all the archives and downloads.

    FileMaker.Advisor.com

    Subscribe to Advisor Basics of FileMaker Pro

    Learn the fundamentals of using FileMaker Pro software. Every issue gives you step-by-step instructions on creating the databases you need. Subscribe now!

    FileMaker.AdvisorBasics.com

    Showcase Your Smarts

    Submit your tips, techniques and advice and let Advisor promote your business and build your career. Show the world what you know!

    AdvisorTips.com

    Use of this or any other site, content, product or service of Advisor Media constitutes acceptance of Terms of Use.
    Portions copyright ©1983-2008 Advisor Media, Inc. All Rights Reserved.
    Reuse or reproduction of any portion or quantity of Advisor Media's copyrighted content, in any form, for any purpose, requires written permission.
    ADVISOR®, the ADVISOR logo, and other names and logos that incorporate ADVISOR are registered trademarks, trademarks or service marks of Advisor Media, Inc. in the United States and/or other countries.
    Other trademarks are used for identification, editorial or descriptive purposes and are the property of their owners.
    Hosted by Prominic.NET Website powered by
    LOTUS SOFTWARE
    GROHM139 posted 04/21/2003 modified 11/21/2008 04:17:42 AM ztdbms/ztdbms
    domino-144.advisor.com my.advisor.com 11/21/2008 09:48:26 PM