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

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)
LVL 1
MilewskpAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Connect With a Mentor Commented:

If application.IsCompiled =  True Then

   ' Do what ever

End If

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Connect With a Mentor Commented:
To compile all modules:

docmd.RunCommand acCmdCompileAllModules

mx
0
 
Dale FyeCommented:
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
btw ... I tested docmd.RunCommand acCmdCompileAllModules (was well as IsCompiled) and they do work.

mx
0
 
MilewskpAuthor Commented:
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
All Courses

From novice to tech pro — start learning today.