Looking to take your VBA skills further?...

Discover twinBASIC — a powerful new development platform that expands on VBA and VB6 with advanced features, modern tools, and enhanced compatibility. Perfect for those ready to elevate their projects or transition from VBA, twinBASIC lets you build on what you already know and take your applications to the next level!

Try out twinBASIC Community Edition - it's free!

Undocumented SysCmd Functions

        44 votes: *****     48,153 views      3 comments
by Wayne Phillips, 19 April 2005    (for Access 97+)

Here are some details on a selection of 'undocumented' SysCmd functions.  You can use these in your Access database applications to do things that generally can't be done easily through the Access Object Model (if at all). 

These details are from a number of sources, including my own research.  They are likely not 100% accurate and they are definitely not official or supported by Microsoft - use them at your own risk!

 SysCmd(603, strPathInputMdb, strPathOutputMde) - CONVERT MDB TO MDE

Convert an MDB file into an MDE.  Since it takes the source file as a parameter, you cannot convert the database currently open using Access VBA - instead you need to call this from another application/instance:

 

    SysCmd 603, strPathInputMdb, strPathOutputMde

OR, by using automation (e.g. in VB6):

        Dim objAccess As Object

        'Create the Access Automation object
        Set objAccess = CreateObject("Access.Application")

        'Now call the undocumented function...
        objAccess.SysCmd 602, strPathSourceMdb, strPathDestinationMdb

        Set objAccess = Nothing

Note: You need to ensure you are using the correct version of Access to create the MDE (i.e. if it is an Access 2000 MDB file then you can only create an MDE from it by using Access 2000 - not Access 2002/2003).

*UPDATE* - It seems that you can use Access XP/2003 to create an Access 2000 MDE file using this method, however be very careful as this is highly likely to fail due to the small differences in compiled VBA code, references and the Access object model etc.  My recommendation is to forget that this loop hole exists.

 

 SysCmd(609) - GET PROCESS ID OF CURRENT INSTANCE - MSACCESS.EXE - Access 2000+ only

Returns the PID (Process ID) of the currently running MSAccess.exe process.  This would come in very handy for some Windows API calls...

 

 SysCmd(504, Flag) - COMPILE VBA MODULES

Where flag can be 16483 to indicate 'Save VBA with compiled code' or 16484 for 'Save VBA without compiled code'.

Flag can also be 16481 and 16482 but the functionality is unknown at present.

 

 SysCmd(602, strPathSourceMdb, [strPathDestinationMdb]) - COMPACT DATABASE - Access 97 only

Compact (not repair) a database.  You cannot compact the *open* database using this method - instead you need to call this from another application/instance:

        Dim objAccess As Object

        'Create the Access Automation object
        Set objAccess = CreateObject("Access.Application") 

        'Now call the undocumented function...
        objAccess.SysCmd 602, strPathSourceMdb, strPathDestinationMdb

        Set objAccess = Nothing

Note: If you want to compact a file without creating a 'copy' (i.e. compacting the file in place) then simply omit the strPathDestinationMdb parameter.

 

 SysCmd(555) - FORCE CREATION OF MSysIMEXSpecs AND MSysIMEXColumns

The two tables that are used to store import/export configurations used by Access are not created by default.  Calling this function will create them for you.

 

 SysCmd(500) - COUNT OF VBA REFERENCES - Access 97 only

Return value is the same as Access.References.Count.

 

 SysCmd(501, intReferenceOrdinal) - RAW STORED STRING OF VBA REFERENCES - Access 97 only

Where 0 <= intReferenceOrdinal <= SysCmd(500)

For each VBA reference, this will return the encoded string which contains all the reference properties (# delimiter) (e.g. GUID#MajorVersion#MinorVersion#LibraryPath#Name)

Something like '*\G{00025E01-0000-0000-C000-000000000046}#4.0#0#C:\Program Files\Common Files\Microsoft Shared\DAO\DAO350.DLL#Microsoft DAO 3.51 Object Library'

 

 SysCmd(605, strPathOutput) - CONVERT DATABASE TO ACCESS 97 FORMAT - Access 2000+ only

Convert the current database to Access 97 format.  If strPathOutput = 0 then the output path is requested.

In Access 2002/2003 this is the same as Access.ConvertAccessProject strSourcePath, strDestinationPath, acFileFormatAccess97

 

 SysCmd(607,strProjectPath) - CONVERT TO ADP PROJECT WITHOUT TABLES/QUERIES  - Access 2000+ only

This command creates a new ADP project and imports the non-Jet components of the currently open database into it (e.g. forms/reports/vba modules).

Note: This is not the same as the Upsizing Wizard as it doesn't do anything with the tables or queries. 

 

 SysCmd(608, intTipID) - VIEW THE OFFICE ASSISTANT TIPS AS STRINGS - Access 2000+ only

These are the tips used by the Office Assistant, accessible by ordinal number (0-60).

 

 SysCmd(710, InputLocaleID) - SET APPLICATION INSTANCE KEYBOARD TYPE

This call is a wrapper for the Win32 API ActivateKeyboardLayout function.

This setting affects the current application instance only and is not saved with the database (you would need to set it within your applications startup routine to make it semi-permanent).  The input flag is called the 'input locale identifier' (see API documents for details).  Examples of common values (notice the high/low word repeats):

    InputLocaleID = &H08090809: British

    InputLocaleID = &H04090409: US English

    InputLocaleID = &04150415: Polish

    InputLocaleID = &04190419: Russian

    InputLocaleID = &H04080408: Greek

 

 SysCmd(711) - GET APPLICATION INSTANCE KEYBOARD TYPE

This call is a wrapper for the Win32 API GetKeyboardLayout function.

This command returns the applications current InputLocaleID (current instance only)  See the flags for previous command (710).

 

 SysCmd(714) - ARE ANY ACCESS OBJECTS IN DESIGN VIEW?

Returns a boolean value (true/false) -  True if any form, report, DAP, macro or module is currently open in design mode.

 

 SysCmd(715) - ACCESS BUILD VERSION

Returns the build number of the version of Access that is running.  Combine this value with the acSysCmdAccessVer SysCmd constant and you can then determine the service pack, e.g.:

    SysCmd(acSysCmdAccessVer) = 9  -> Access 2000

        SysCmd(715) = 2719 ' Access 2000 No Service Pack

        SysCmd(715) = 3822 ' Access 2000 SP1

        SysCmd(715) = 4506 ' Access 2000 SP2

        SysCmd(715) = 6620 ' Access 2000 SP3

    SysCmd(acSysCmdAccessVer) = 10  -> Access 2002

        SysCmd(715) = 2627 ' Access 2002(XP) No Service Pack

        SysCmd(715) = 3409 ' Access 2002(XP) SP1

        SysCmd(715) = 4302 ' Access 2002(XP) SP2

        SysCmd(715) = 6501 ' Access 2002(XP) SP3

    SysCmd(acSysCmdAccessVer) = 11  -> Access 2003

        SysCmd(715) = 5614 ' Access 2003 No Service Pack

        SysCmd(715) = 6355 ' Access 2003 SP1

        SysCmd(715) = 6566 ' Access 2003 SP2


 

 SysCmd(712) - GET IPictureDisp FROM IMAGE CONTROL - Access 2000+ only

Returns a pointer to the IPictureDisp interface behind an image control.

 

If you know of any more, feel free to e-mail them to contact us so we can update the list.

*Microsoft Access is a trademark of Microsoft Corporation in the United States and other countries*

IMPORTANT: This document may not be reproduced in part or whole without prior consent from the author.

EverythingAccess.com

 

Rate this article:  Your rating: PoorYour rating: Not so goodYour rating: AverageYour rating: GoodYour rating: Excellent


Have your say - comment on this article.

What did you think of 'Undocumented SysCmd Functions'?


1.

Paulo Jm says...

09 Dec 2009

 
Very good

2.

Simon Lampen says...

22 Dec 2010

 
It appears that converting to ADE or MDE using this method may fail if the source and destination are passed as ref-able variables.
To force these variables to be passed byval or to de-reference them, wrap each in a function call such as VBA.Trim(sourcedb) etc.
eg:
app.SysCmd 603, VBA.Trim(sourceFile_), VBA.Trim(compiledFileName_)

This was my experience using Access 2010 on Windows 7.
If I passed the variables straight a scambled unicode file name would appear in a parent directory for the destdb and the function would not find the sourcedb if I left the sourcedb using the straight variable.

Hope this helps.

3.

Wayne Phillips says...

23 Dec 2010

 
Thanks for the information, Simon.

Someone had reported this to me previously but at the time I was too busy to check it myself. That was several years ago, therefore I assume the issue also affects earlier versions of Access as well.

Cheers.

Have your say...

Name
E-mail (e-mail address will be kept private)
Comments


Comments require approval before being displayed on this page (allow 24 hours).