Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

Modules: Compile Project

Author(s)
Dev Ashish

  In Access 97, changes to any module code results in the project becoming decompiled.  For best performance, it is suggested that the option "Compile and Save All Modules" be selected in such cases.

    Here's a function that could be run from anywhere in the database and which automatically compiles and saves all code in a database.

'********** Code start **********
'This code was originally written by Dev Ashish
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Dev Ashish
'
 Function fCompileProject() As Boolean
 Dim db As Database
 Dim ctr As Container

     If Not Application.IsCompiled Then
        Set db = CurrentDb
        Set ctr = db.Containers!Modules
        If ctr.Documents.Count > 0 Then
           DoCmd.OpenModule ctr.Documents(0).Name
        Else
            'No Modules present, try Forms container
            Set ctr = db.Containers!Forms
            'no need to check for count since this code
            'itself must be present *somewhere*
            DoCmd.OpenForm ctr.Documents(0).Name
        End If
        DoCmd.RunCommand acCmdCompileAndSaveAllModules
        DoCmd.Close acModule, ctr.Documents(0).Name
     End If

     fCompileProject = Application.IsCompiled
 End Function
 '*********** Code End **********

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer