Solved

How VBA code can tell if it's not compiled, and how it can compile itself

Posted on 2010-11-29
5
261 Views
Last Modified: 2013-11-27
Is there a way you can tell if all of the VBA modules of a project are compiled or not (using a VBA procedure, that is)?
Can you run a VBA procedure to compile all modules of a VBA project (or at least all of the modules other than the one the procedure is in)?

Note:
EE expert Jim Dettman says there is an undocumented SYSCMD function (SysCmd(504, 16483) ) available in MS Access that will compile all modules, but advises not to use it. (Ref: http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_26639269.html#a34231494 ID:34230641)
0
Comment
Question by:Milewskp
  • 3
5 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 34231648

If application.IsCompiled =  True Then

   ' Do what ever

End If

mx
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 34231657
To compile all modules:

docmd.RunCommand acCmdCompileAllModules

mx
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 34231695
There is a RunCommand constant (two actually) that might work, but I have never tried either:

Docmd.RunCommand acCmdCompileAllModules

or

Docmd.RunCommand acCmdCompileAndSaveAllModules
You can check these out at Terry Wickenden's site: http://www.accessruncommand.com/index.htm
The second one actually contains a code example.

0
 
LVL 75
ID: 34231757
btw ... I tested docmd.RunCommand acCmdCompileAllModules (was well as IsCompiled) and they do work.

mx
0
 
LVL 1

Author Comment

by:Milewskp
ID: 34232007
Thanks mx!

Hi fyed,
I tried Terry's code. It appears to be unnecessarily complicated, since mx's one liners seems to work fine (for A2003 SP3 anyway).

0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now