Solved

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

Posted on 2010-11-29
5
270 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 - Microsoft MVP, Access and Data Platform) 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 - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) 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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

830 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